使用gnuplot的条件的xtics标签

时间:2018-06-24 08:58:30

标签: plot gnuplot conditional-statements labeling

我对用文件中一列中的字符串标记xtics感兴趣。 该文件以以下方式写入:

Index Name Status Value
1 Ver1 with 0.3
2 Ver1 without 0.25
3 Ver2 with 0.35
4 Ver3 with 0.27

应使用条件图绘制数据

plot file u (strcol(3) eq "with"?$1:1/0):($4) w p pt 7 notitle

xtics应当用列(2)中包含的数据标记。如果使用了所有值,则可以通过xticlabel(2)完成。但是我只想使用过滤后的数据来获得如下图:

|
|     x      x     x
|     
----------------------------
    ver1   ver2   ver3

问题是:如何仅使用过滤后的值标记xtics?

谢谢!

1 个答案:

答案 0 :(得分:0)

您也可以在xticlabel中施加相同的条件,即,如果需要,则使用第2列,或者改为传递未定义的值:

plot 'file.dat' u \
  (strcol(3) eq "with"?$1:1/0):4:xticlabel((strcol(3) eq "with")?strcol(2):1/0) \
  w p pt 7 notitle