我正在尝试在gnuplot(版本4.4)中创建一个带有变量颜色(和行宽)的2D矢量图。我看了几个例子:
splot "vectors.dat" u 1:2:3:4:(rgb($5,$6,$7)) w points pt 7 pointsize var linecolor rgb variable
其中 rgb 是一种将颜色转换为gnuplot友好格式的函数。
对矢量的修改似乎很简单,但我偶然发现了几个问题。我的示例代码是(用于变量着色):
splot "vectors.dat" u 1:2:(rgb($5,$6,$7)):3:4:(rgb($5,$6,$7)) with vectors head filled size screen 0.05,15,45 linetype 1 linewidth 2 linecolor rgb variable
我还尝试在第三列中放置0,因为向量的gnuplots表示法是(x,y,z)(dx,dy,dz)。此外,我还尝试交换列,并使用随机值。但无论我做什么,箭头都是黑色的。
我有什么明显的遗失吗?
提前致谢,
Arash的
答案 0 :(得分:5)
我只会使用一种颜色规格,例如
set xrange [0:10]
set yrange [0:10]
plot "test.dat" using 1:2:3:4:5 with vectors lw 3 lc rgb variable
test.dat
包含
1 1 2 0 0x000000
1 2 2 0 0xff0000
1 3 2 0 0xffff00
1 4 2 0 0x382288
使用以下内联rgb
函数
rgb(r,g,b) = int(r)*65536 + int(g)*256 + int(b)
plot "test2.dat" using 1:2:3:4:(rgb($5,$6,$7)) with vectors lw 3 lc rgb variable
test2.dat
现在读取
1 1 2 0 0 0 0
1 2 2 0 255 0 0
1 3 2 0 255 255 0
1 4 2 0 56 34 136
答案 1 :(得分:3)
假设您想按矢量幅度为数据文件着色,您还可以将palette
选项与cbrange
结合使用,例如(Gnuplot 4.6例子)
set cbrange [0:1]
set palette rgbformulae 33,13,10
plot "data" using 1:2:3:4:(sqrt($3**2+$4**2)) with vectors linecolor palette z