gnuplot 密钥生成问题
gnuplot key generating issue
我有这样的文件格式:
2014/3/12 18:02:36 1 SSID1
2014/3/12 18:02:37 1 SSID1
2014/3/12 18:02:38 2 SSID2
2014/3/12 18:02:39 1 SSID1
2014/3/12 18:02:39 3 SSID3
2014/3/12 18:02:39 3 SSID3
2014/3/12 18:02:39 2 SSID2
我创建了一个 gnuplot 脚本来绘制日历方案 -> X 中的日期和 Y 中的小时,每个连接到 SSID 的点)。我使用 lc 变量生成与 column(3) 不同的颜色。
reset
clear
file_exists(file) = system("[ -f '".file."' ] && echo '1' || echo '0'") + 0
fontsize(x)=((GPVAL_TERM eq 'postscript') && \
(strstrt(GPVAL_TERMOPTIONS,"eps")!=0)) ? x*2 : x
set xdata time
set ydata time
set timefmt x "%Y/%m/%d"
set timefmt y "%H:%M:%S"
day = 360*24
set xtics 70*day
set format y "%H"
set format x "%B %d"
set ylabel "Time (Hour)"
set xlabel "Date (Month Day)" offset -1,0
set xlabel font 'Arial-Bold, 15"
set ylabel font 'Arial-Bold, 15"
set xtics rotate
set xtics font "Arial-bold, 15"
set ytics font "Arial-Bold, 15"
set style data points
set terminal png size 3200,2400
do for [i=2:2] {
if ( file_exists("data".i.".dat") ) {
set output sprintf("%s.png", "data".i)
set key box below
set title "Different SSID Wifi on color"
plot "data".i.".dat" using 1:2:3 linecolor variable pt 7 ps 1 t columnhead(4)
}
}
但我没有正确的图例(键)。使用我的代码,我只有一个盒子,第一个 SSID 在第 (4) 列,颜色正确......但是我如何才能在这个盒子里拥有所有 SSID 和所有可变颜色?
用title columnheader(4)
你select第一行的第四列作为整个情节的关键标题。要获得正确的标题,以及键中正确的线条颜色(参见 Different color per dataset 关于 linecolor variable
的键颜色),最好生成一个包含所有唯一 SSID 的列表,然后遍历它们:
file = 'data2.dat'
SSIDs = system(sprintf('awk ''{print }'' %s | sort | uniq', file))
set xdata time
set ydata time
set timefmt x "%Y/%m/%d"
set timefmt y "%H:%M:%S"
day = 360*24
set xtics 70*day
set format y "%H"
set format x "%B %d"
set style data points
plot for [s=1:words(SSIDs)] file using (strcol(4) eq word(SSIDs, s) ? timecolumn(1) : 1/0):2:3 lc s pt 7 ps 1 t word(SSIDs, s)
请注意,使用此 1/0
技巧在绘制 with points
时效果很好。如果由于某种原因你想绘制线条,你必须使用例如过滤。 grep
:
cmd(s, f) = sprintf('< grep ''%s'' %s', s, f)
plot for [s=1:words(SSIDs)] cmd(s, file) using 1:2:3 lc s pt 7 ps 1 t word(SSIDs, s)
我有这样的文件格式:
2014/3/12 18:02:36 1 SSID1
2014/3/12 18:02:37 1 SSID1
2014/3/12 18:02:38 2 SSID2
2014/3/12 18:02:39 1 SSID1
2014/3/12 18:02:39 3 SSID3
2014/3/12 18:02:39 3 SSID3
2014/3/12 18:02:39 2 SSID2
我创建了一个 gnuplot 脚本来绘制日历方案 -> X 中的日期和 Y 中的小时,每个连接到 SSID 的点)。我使用 lc 变量生成与 column(3) 不同的颜色。
reset
clear
file_exists(file) = system("[ -f '".file."' ] && echo '1' || echo '0'") + 0
fontsize(x)=((GPVAL_TERM eq 'postscript') && \
(strstrt(GPVAL_TERMOPTIONS,"eps")!=0)) ? x*2 : x
set xdata time
set ydata time
set timefmt x "%Y/%m/%d"
set timefmt y "%H:%M:%S"
day = 360*24
set xtics 70*day
set format y "%H"
set format x "%B %d"
set ylabel "Time (Hour)"
set xlabel "Date (Month Day)" offset -1,0
set xlabel font 'Arial-Bold, 15"
set ylabel font 'Arial-Bold, 15"
set xtics rotate
set xtics font "Arial-bold, 15"
set ytics font "Arial-Bold, 15"
set style data points
set terminal png size 3200,2400
do for [i=2:2] {
if ( file_exists("data".i.".dat") ) {
set output sprintf("%s.png", "data".i)
set key box below
set title "Different SSID Wifi on color"
plot "data".i.".dat" using 1:2:3 linecolor variable pt 7 ps 1 t columnhead(4)
}
}
但我没有正确的图例(键)。使用我的代码,我只有一个盒子,第一个 SSID 在第 (4) 列,颜色正确......但是我如何才能在这个盒子里拥有所有 SSID 和所有可变颜色?
用title columnheader(4)
你select第一行的第四列作为整个情节的关键标题。要获得正确的标题,以及键中正确的线条颜色(参见 Different color per dataset 关于 linecolor variable
的键颜色),最好生成一个包含所有唯一 SSID 的列表,然后遍历它们:
file = 'data2.dat'
SSIDs = system(sprintf('awk ''{print }'' %s | sort | uniq', file))
set xdata time
set ydata time
set timefmt x "%Y/%m/%d"
set timefmt y "%H:%M:%S"
day = 360*24
set xtics 70*day
set format y "%H"
set format x "%B %d"
set style data points
plot for [s=1:words(SSIDs)] file using (strcol(4) eq word(SSIDs, s) ? timecolumn(1) : 1/0):2:3 lc s pt 7 ps 1 t word(SSIDs, s)
请注意,使用此 1/0
技巧在绘制 with points
时效果很好。如果由于某种原因你想绘制线条,你必须使用例如过滤。 grep
:
cmd(s, f) = sprintf('< grep ''%s'' %s', s, f)
plot for [s=1:words(SSIDs)] cmd(s, file) using 1:2:3 lc s pt 7 ps 1 t word(SSIDs, s)