如何绘制多个不同颜色的向量?

How to draw multiple vectors with different color?

我想用 gnuplot 画线。 数据文件是:

#X1 y1 x2 y2 colorNumber
123 567 798 900 1
788 900 87  89 2
....

我创建一个调色板

set palette model RGB defined ( 1 'violet', 2 'red', 3 'blue', 4 'yellow', 5 'green', 6 'orange', 7 'cyan')

如何用颜色绘制每条线?

我尝试了 followng 但效果不佳。

plot '~/Desktop/pointcolor.txt' using 1:2:(-):(-):3 with vectors palette nohead notitle

这是结果,问题是线条颜色与我定义的颜色不匹配。

您的数据文件一共包含五列,第五列包含您想要的颜色编号。所以你需要

plot '~/Desktop/pointcolor.txt' using 1:2:(-):(-):5 with vectors palette nohead notitle