基于数组索引的gnuplot中的标题

时间:2018-01-19 13:03:07

标签: gnuplot

我有一个数组,其值如:

percentile="P5,P10,P20,P25,P50,P75"

我在gnuplot中使用for循环进行迭代,有点像这样:

plot for [i=2:4] "Stats.data" using (column(1)):(column(i)) title "${percentile[i]}".i

我想要的是从百分位数阵中获取的标题。但这并没有发生。

错误:无效命令

1 个答案:

答案 0 :(得分:3)

如果在您的Gnuplot脚本中将percentile表示为字符串,那么您可以使用word函数从提供的字符串中提取相应的空白分隔的单词(单词索引为1-基于)

percentile="P5 P10 P20 P25 P50 P75"

plot for [i=2:4] "Stats.data" using (column(1)):(column(i)) w l title word(percentile, i+1)