2017-04-18 68 views
1

我正在绘制一个带有不同列的文件,我正在使用gnuplot的for循环。我想完全控制图形的外观,所以我使用set line style来控制线条的颜色。我想对模式填充做同样的事情,但似乎用gnuplot是不可能的。Gnuplot fillstyle pattern with word function given error

到目前为止,我已经得出这样的解决方案,它不工作为好,原因不明:

set terminal cairolatex standalone pdf 
set style line 2 linecolor rgbcolor "#F9E0B0" linewidth 2 pt 13 
# etc ... up to 10 

pat="0 2 4 7 2 4 7 2 4 7" ## An attempt to define the pattern style I want 
set style fill pattern 1 border ## this control the first pattern, then the next ones are incremented but it cannot control each index 

set output "myplot.tex" 
plot for [i=2:10] "myfile.dat" index 0 u i:xtic(1) fillstyle pattern int(word(pat, i)) ls i ti columnheader ## The color is controlled according to me via the linestyle, but the fillstyle does not work 

## An alternate solution giving a little bit of control but not fully satisfactory since I want to avoid the pattern 3 
# plot for [i=2:10] "myfile.dat" index 0 u i:xtic(1) fillstyle pattern i%3+1 ls i ti columnheader 
unset output 

有了这个解决方案,我得到以下错误:unexpected or unrecognized token

任何想法,为什么字失败在fillstyle模式之后,还是没有人有关于如何为每个数据指定模式的想法?

编辑:我使用的gnuplot 5.0

回答

2

解析器期待实体紧随其后的“填充样式”是一个数字,但它不承认INT(“富”)为数字。这是一个错误。您可以通过使用替代语法来解决此问题

fillstyle pattern 0+word(pat,i) 
+0

它完美地工作。 – Jean