GnuPlot中的线图,其中线条颜色是我的数据文件中的第三列?

Gab*_*abe 29 plot graph gnuplot

我有一个如下所示的数据文件:

1 1.0 0
2 1.5 0
3 0.0 1
4 1.2 2
5 1.0 1
6 1.1 1
Run Code Online (Sandbox Code Playgroud)

第一列是我的X值,第二列是我的Y值,第三列是颜色.我想根据第三列对每个线段进行着色.所以前两个线段是"颜色1",下一个是"颜色2",下一个是"颜色3",最后两个再次是"颜色1".

我试过了:

plot 'file.dat' using 1:2:3 with lines rgb variable;
Run Code Online (Sandbox Code Playgroud)

但我的线条全黑了.

这可能在gnuplot中吗?

谢谢,加布

Tom*_*Tom 26

以下内容适用于我(gnuplot 4.4)

plot "./file.dat" u 1:2:3 with lines  palette
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助.

当我运行你的代码时,gnuplot无法传递"rgb"部分.

有关使用变量标签的示例,请参阅类似的问题: GNUPLOT:点图,数据取决于点大小

这里有一些有用的例子:http: //gnuplot.sourceforge.net/demo/pointsize.html

祝一切顺利

汤姆


小智 12

plot 'foo.dat' with lines linecolor variable
Run Code Online (Sandbox Code Playgroud)

或缩写:

plot 'foo.dat' w l lc var
Run Code Online (Sandbox Code Playgroud)

  • 您是否知道如何为"变量"颜色创建图例/标题? (2认同)

小智 11

很久以前就问过这个问题,但我刚才有同样的问题.并且最适合获得"变量"颜色的图例/标题的方法是:

# set this to the range of your variable which you want to color-encode
# or leave it out
set cbrange [0:1]

# define the palette to your liking
set palette defined ( 0 "#B0B0B0", 0.333 "#FF0000", 0.666 "#0000FF", 1.0 "#000000" )

# in this example, column 3 is mapped to the colors of the palette
plot "data.txt" u 1:2:3 w l lc palette z
Run Code Online (Sandbox Code Playgroud)

(在gnuplot 4.6 patchlevel 4上测试)