使用带点的可变颜色

时间:2014-09-09 16:56:55

标签: gnuplot

我有一个格式为

的数据文件
<color>  <point>

例如,文件看起来像

AABBCC   10
0A0B0C   20
1A1B1C   30
...

因此,X轴是行号,Y轴是第二列。还有一个类似的问题here。但是,它并不符合我的需要,因为我没有三种列格式。此外,在我的文件中,我已经定义了颜色,因此不需要使用调色板(至少,这是我的想法!)。

因此,我不知道如何修改命令。

更新

Christoph说,运行命令只显示块颜色。这是屏幕截图

enter image description here

1 个答案:

答案 0 :(得分:2)

使用选项linecolor rgb variable,您可以指定一个表示rgb-tuple的整数。因此,对于您的数据文件,您只能将十六进制值转换为十进制值。

在Linux上,您可以使用real函数进行此转换,并将字符串0x添加到数据值中:

plot 'test.dat' using 0:2:(real('0x'.strcol(1))) linecolor rgb variable pt 7 ps 2

不幸的是,这在Windows上不起作用,print real('0xAABBCC')之类的内容总是返回0.0。

以下是十六进制rgb值到整数的仅限gnuplot的转换函数:

hex = '123456789ABCDEF'
hex_to_int(s) = strstrt(hex, s[1:1])*2**20 + \
                strstrt(hex, s[2:2])*2**16 + \
                strstrt(hex, s[3:3])*2**12 + \
                strstrt(hex, s[4:4])*2**8 + \
                strstrt(hex, s[5:5])*2**4 + \
                strstrt(hex, s[6:6])
plot 'test.txt' using 0:2:(hex_to_int(strcol(1))) linecolor rgb variable pt 7 ps 2