Gnuplot:从 csv 文件中获取子字符串

Gnuplot: substring fetching from csv file

我正在尝试从 csv 捕获中提取字符串。我正在尝试在图表上绘制标签。

data.csv

"No.","Time","Source","Destination","Protocol","Info"
"2","0.000252","192.168.1.183","224.0.0.251","802.11","Standard query 0x0000 ANY 43684enet3-15988.local, ""QM"" question HINFO X86_64 LINUX"
"3","0.000553","192.168.1.183","224.0.0.251","802.11","Standard query response 0x0000 AAAA, cache flush fe80::e2d5:5eff:fe51:b860 A, cache flush 192.168.1.183"

我尝试绘制字段的子字符串,使用脚本:

set colors classic
set terminal svg size 360,460
set output 'reading.svg'

set datafile separator ","
set xdata time
set timefmt "%s.%.6s"
set xtic rotate 90

plot 'data.csv' u 1:2:(substr(,1,3)):xtic(2) with labels

我试图从列中提取子字符串。但它给出了以下错误:

C:\Users\ys928695\Box\TWT>gnuplot script.gpc
"script.gpc" line 19: internal error: substring range operator applied to non-STRING type

gnuplot 将 </code> 解释为浮点数。如果你想将它解释为字符串,你需要使用 <code>strcol()stringcolumn(),参见 help stringcolumn.

所以以下应该有效:

plot 'data.csv' u 1:2:(substr(strcol(4),1,3)) with labels

对了,your other recent question也是一样,如果你想用秒作为x轴,我不会用xtic(2)