我有以下数据:
ClockIndex Max AvgStd Avg Num Threshold
"ck1 (1.54 GHz)" 35 +16.30 11 11583 X
"ck2 (1.54 GHz)" 28 +16.66 12 10669 -
"ck3 (1.54 GHz)" 29 +14.47 9 8036 -
"ck4 (1.54 GHz)" 35 +18.99 12 5685 -
"ck5 (1.54 GHz)" 9 +6.04 3 11 -
我在一个点图中一起绘制第2,3,4列,每个条目一行。
使用此代码:
set xtics rotate
set xlabel ""
set ylabel "Levels"
set title "Levels - foo"
set key autotitle columnhead
set term png medium size 1200,600
set grid
set output "foo.png"
plot "foo.rpt" using 2:xticlabels(1) with points pt 13 ps 2 lt rgb "blue",\
"" using 3:xticlabels(1) with points pt 13 ps 2 lt rgb "red",\
"" using 4:xticlabels(1) with points pt 13 ps 2 lt rgb "black
**目标:如果“阈值”列中有“X”,我希望“最大”点为绿色,而不是蓝色。
我尝试过使用awk,但无济于事。
plot "< awk '{if($6 == \"X\") print }' foo.rpt" using 2:xticlabels(1) with points pt 13 ps 2 lt rgb "blue",\
"" using 3:xticlabels(1) with points pt 13 ps 2 lt rgb "red",\
"" using 4:xticlabels(1) with points pt 13 ps 2 lt rgb "black"
"< awk '{if($6 == \"-\") print }' foo.rpt" using 2:xticlabels(1) with points pt 13 ps 2 lt rgb "green",\
"" using 3:xticlabels(1) with points pt 13 ps 2 lt rgb "red",\
"" using 4:xticlabels(1) with points pt 13 ps 2 lt rgb "black"
我一直收到如下错误:
"foo_gnuplot", line 11: warning: Skipping data file with no valid points
任何帮助将不胜感激!非常感谢您一起来看看! :)
答案 0 :(得分:1)
你可以这样做:
plot "foo.rpt" using 2:xticlabels(1) with points pt 13 ps 2 lt rgb "blue",\
"" using 3:xticlabels(1) with points pt 13 ps 2 lt rgb "red",\
"" using 4:xticlabels(1) with points pt 13 ps 2 lt rgb "black",\
"" using (strcol(6) eq "X" )?($2):(1/0):xticlabels(1) with points pt 13 ps 2 lt rgb "green"
(condition)?($plotThisValue):(1/0)
是条件绘图的常用gnuplot技术。
使用该代码,原始点用绿色点叠印。 (如果要完全删除原始(现在隐藏)蓝点,可以在绘图命令的第一行中使用相同的技术。)
答案 1 :(得分:0)
非常感谢havogt的出色答案!这就是我最终做的事情:
plot "foo.rpt" using 3:xticlabels(1) with points pt 13 ps 2 lt rgb "red",\
"" using 4:xticlabels(1) with points pt 13 ps 2 lt rgb "black",\
"" using (strcol(6) eq "X" )?($2):(1/0):xticlabels(1) with points pt 13 ps 2 lt rgb "green"
"" using (strcol(6) eq "-" )?($2):(1/0):xticlabels(1) with points pt 13 ps 2 lt rgb "blue"
效果很好!真的很感激帮助!