31

我有一个看起来像这样的数据文件:

1 1.0 0
2 1.5 0
3 0.0 1
4 1.2 2
5 1.0 1
6 1.1 1

其中第一列是我的 X 值,第二列是我的 Y 值,第三列是颜色。我希望根据第三列对每个线段进行着色。所以前两个线段是“颜色 1”,下一个是“颜色 2”,下一个是“颜色 3”,最后两个线段又是“颜色 1”。

我试过了:

plot 'file.dat' using 1:2:3 with lines rgb variable;

但是我的线全是黑色的。

这在gnuplot中可能吗?

谢谢, 加布

4

3 回答 3

26

以下对我有用(gnuplot 4.4)

plot "./file.dat" u 1:2:3 with lines  palette

希望这可以帮助。

当我运行您的代码时,gnuplot 无法通过“rgb”部分。

有关使用变量标签的示例,请参见类似的问题: GNUPLOT: dot plot with data based dot size

在这里找到有用的例子:http: //gnuplot.sourceforge.net/demo/pointsize.html

一切顺利

汤姆

于 2010-11-06T20:25:36.820 回答
13

很久以前就有人问过这个问题,但我也有同样的问题。获得“可变”颜色的图例/标题的最合适方法是:

# 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

(在 gnuplot 4.6 补丁级别 4 上测试)

于 2014-05-08T10:00:59.123 回答
13
plot 'foo.dat' with lines linecolor variable

或缩写:

plot 'foo.dat' w l lc var
于 2011-08-19T12:59:32.570 回答