的lc rgb variable
将任何字符串整数转换他们评估的颜色之前,这将不将字符串“red”转换为数字0xff0000。所以我们必须定义我们自己的转换函数。
你可以使用这个想法从答案https://stackoverflow.com/a/35729052/7010554。这里是一个可能的实现:
colorSet(name, rgb) = sprintf("color_%s = %d", name, rgb)
colorGet(name) = value(sprintf("color_%s", name))
eval colorSet("magenta", 0xff00ff)
eval colorSet("red", 0xff0000)
eval colorSet("green", 0x00ff00)
eval colorSet("black", 0x000000)
eval colorSet("dark_yellow", 0xc8c800)
print colorGet("green")
print color_green
set xrange [0:10]
set yrange [0:10]
plot "input.dat" using 1:2:3:4:(colorGet(stringcolumn(5))) with vectors lw 3 lc rgb variable
colorSet(name, rgb)
和`colorGet(名称),将创建函数和变量的访问与形式COLOR_GREEN的名字,COLOR_RED,...这些变量的值相应的rgb值。
您可以随意定义颜色,名称不得包含连字符。 gnuplot内部颜色定义由命令show colors
显示。
我并不期望定义自己的转换函数。作为定义的颜色名称,我认为它会更简单。但是谢谢@maij,这解决了我的问题。 – ACR