标签: colors gnuplot
对于功能图(即不是来自数据文件),我想根据x值更改绘图的颜色。 例如,我按如下方式定义调色板: set palette defined ( 0 'purple', 1 'blue', 2 'green', 3 'yellow', 4 'orange', 5 'red' ) 我希望根据范围[0:5]的x值使用我的调色板使用函数sin(x)的颜色。 怎么办呢?
set palette defined ( 0 'purple', 1 'blue', 2 'green', 3 'yellow', 4 'orange', 5 'red' )
sin(x)
答案 0 :(得分:2)
您可以使用linecolor palette来实现此目的,这需要指定包含颜色信息的附加列。对于函数图,您可以使用特殊文件名'+'来使using命令完全具有多功能性:
linecolor palette
'+'
using
set palette defined ( 0 'purple', 1 'blue', 2 'green', 3 'yellow', 4 'orange', 5 'red' ) set xrange [0:5] plot '+' using 1:(sin($1)):1 with lines linewidth 3 linecolor palette