Variables Gnuplot:二维矢量图的可变颜色(和线宽)
我试图在gnuplot(版本4.4)中创建一个带有变量颜色(和线宽)的二维矢量图。我看了一些例子,想了解以下几点:Variables Gnuplot:二维矢量图的可变颜色(和线宽),variables,vector,colors,gnuplot,Variables,Vector,Colors,Gnuplot,我试图在gnuplot(版本4.4)中创建一个带有变量颜色(和线宽)的二维矢量图。我看了一些例子,想了解以下几点: splot "vectors.dat" u 1:2:3:4:(rgb($5,$6,$7)) w points pt 7 pointsize var linecolor rgb variable 其中rgb是将颜色转换为gnuplot友好格式的函数 对向量的修改似乎很简单,但我遇到了几个问题。我的示例代码是(用于变量着色): 我还尝试将0放在第三列,因为向量的gnuplots表示法
splot "vectors.dat" u 1:2:3:4:(rgb($5,$6,$7)) w points pt 7 pointsize var linecolor rgb variable
其中rgb是将颜色转换为gnuplot友好格式的函数
对向量的修改似乎很简单,但我遇到了几个问题。我的示例代码是(用于变量着色):
我还尝试将0放在第三列,因为向量的gnuplots表示法是(x,y,z)(dx,dy,dz)。此外,我还尝试交换列,并使用随机值。但无论我做什么,箭都是黑色的
我有什么明显的遗漏吗
提前感谢,
阿拉什我只会使用一种颜色规格,例如
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
假设您希望按矢量大小为数据文件着色,也可以将
调色板
选项与cbrange
结合使用,例如(Gnuplot 4.6示例)
谢谢,成功了!在回顾中,使用splot而不是plot似乎很愚蠢…@Arash很高兴听到它有帮助。你知道为什么我在尝试你的例子时会出现“太多使用这种样式的规范”的错误吗?我使用的是4.2(它是4.4特性吗?@Bernhard-我相信这是因为这个例子是针对有4个参数的向量,加上颜色是第5个参数(或“spec”)。
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
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