产生带有十进制数字的可变颜色 [英] producing variable colors with decimal numbers
问题描述
我创建了一个文件,看起来第一列是十进制颜色线,第二列是y轴. x轴是行号.
I created a file which looks like where the first column is the color line in decimal and the second column is y-axis. The x-axis is the row number.
0 0
1 1
2 2
...
然后我运行此命令
plot "test.dat" u 0:2:1 pt 7 ps 1 lc rgb variable
如您在图片中所见,输出仅包含黑色到蓝色的范围.
As you can see in the picture, the output contains a range of black to blue colors only.
为什么?
如何产生其他颜色?
推荐答案
基本上,您可以在linecolor rgb variable
,linecolor variable
和linecolor palette
这三个选项之间进行选择.您使用哪种,以及如何使用取决于您的实际需求.
Basically you have the choice between three options, linecolor rgb variable
, linecolor variable
and linecolor palette
. Which one you use and how depends on your actual requirements.
-
当使用
linecolor rgb variable
时,最后一列中给出的值用作rgb-tuple的整数表示,即,最低字节是蓝色部分,第二最低的是绿色部分,第三字节是红色部分.这就是你所拥有的.
When you use
linecolor rgb variable
, the value given in the last column is used as integer representation of an rgb-tuple, i.e. the lowest byte is the blue part, the second lowest the green part and the third byte is the red component. This is what you have.
要使用此选项,您必须在数据文件中具有完整的rgb-integer值,例如
For using this option you must either have the full rgb-integer values in your data file, like
0 13.5 # black
0 17
65280 12 # green (255 * 2**8)
0 19.3
16711680 14.7 # red (255 * 2**16)
65280 10
16711680 22
然后使用
plot 'test.txt' using 0:2:1 linecolor rgb variable pt 7
或者将红色,绿色和蓝色分量分别保存在一列中,然后使用gnuplot函数计算rgb-integer:
Alternatively you save the red, green and blue components in one column each and use a gnuplot function to calculate the rgb-integer:
0 0 0 13.5 # black
0 0 0 17
0 255 0 12 # green
0 0 0 19.3
255 0 0 14.7 # red (255 * 2**16)
0 255 0 10
255 0 0 22
然后使用
rgb(r,g,b) = 65536 * int(r) + 256 * int(g) + int(b)
plot 'test.txt' using 0:4:(rgb($1,$2,$3)) linecolor rgb variable pt 7
使用linecolor variable
会将最后一列用作linetype
索引.大索引将包装到已定义的线型集:
Using linecolor variable
would use the last column as linetype
index. Large indices are wrapped to the set of defined linetype:
set xrange [0:1000]
plot '+' using 1:1:0 linecolor variable pt 7
使用linecolor palette
将最后一列用作调色板的索引:
Using linecolor palette
uses the last column as index for the color palette:
set xrange [0:1000]
plot '+' using 1:1:0 linecolor palette pt 7
您使用哪种变体可能取决于不同颜色的数量和颜色的分布.
Which variant you use may depend both on the number of different colors and the distribution of the colors.
这篇关于产生带有十进制数字的可变颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!