Gnuplot-根据x值为图着色 [英] Gnuplot - coloring a plot according to x-value
问题描述
对于函数图(即不是来自数据文件),我想根据x值更改图的颜色。
例如,我定义了一个调色板,如下所示:
设置了已定义的调色板(0'紫色',1'蓝色',2'绿色',3 'yellow',4'orange',5'red')
,我希望使用颜色 sin(x)
根据范围[0:5]的x值使用我的调色板。
如何完成?
I would like to change the color of a plot according to the x-value, for a function plot (i.e. not from a data file).
For example, I define a palette as follows:
set palette defined ( 0 'purple', 1 'blue', 2 'green', 3 'yellow', 4 'orange', 5 'red' )
and I wish to use the color the function sin(x)
using my palette according to the x value for the range [0:5].
How can this be done?
推荐答案
您可以使用 linecolor调色板
为此,它需要指定一个包含颜色信息的附加列。对于功能图,您可以使用特殊文件名'+'
来使用 using
命令的全部功能。处置:
You can use linecolor palette
for this purpose, which requires the specification of an additional column that contains the color information. For a function plot you can use the special filename '+'
to have the full versatility of the using
command at your disposal:
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
这篇关于Gnuplot-根据x值为图着色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!