无法在 GNUPlot 中为标签着色
Cannot get labels to color in GNUPlot
一段时间以来我一直在处理这个文件的一些变种:
$DATA << EOD
0.910731391716549 0.0917930320554009 LABEL1 '#008000'
0.871162274545609 0.181191762678911 LABEL2 '#ffff00'
EOD
set key off
set border 3; set tics nomirror
set xrange [0:*]
plot "$DATA" using 1:2:3:4 with labels textcolor rgb variable
这是基于
应该制作一个散点图,标签为 LABEL1
和 LABEL2
但是当我 运行 GNUPlot gnuplot 5.2 patchlevel 8 我得到这个错误:
"/tmp/oBjdIStjpA" line 13: warning: Skipping data file with no valid points
plot "$DATA" using 1:2:3:4 with labels textcolor rgb variable
^
"/tmp/oBjdIStjpA" line 13: x range is invalid
这个错误毫无意义。
如果我将 plot
行更改为 plot "$DATA" using 1:2:3:4 with labels
GNUPlot 可以工作,但没有我想要的颜色。
我没有使用与其他发帖人相同的颜色编码,而且我不知道如何转换为其他发帖人使用的任何十进制编码。
如何获得每个点的颜色?
勾选help colorspec
。那里说 textcolor rgb variable
取数值(不是文本)。
因此,如果您将 '#008000'
和 '#ffff00'
更改为 0x008000
和 0xffff00
,它应该可以工作。
加法:
如果您不想更改原始数据,只需定义一个将字符串转换为整数的函数即可。
代码:
### string color variable to integer
reset session
$Data <<EOD
1 1 Label1 '#ff0000'
2 2 Label2 '#00ff00'
3 3 Label3 '#0000ff'
4 4 Label4 '#ff00ff'
5 5 Label5 '#ffff00'
6 6 Label6 '#00ffff'
EOD
unset key
set xrange [0:7]
set yrange [0:7]
myColor(col) = int('0x'.strcol(col)[3:])
plot $Data using 1:2:3:(myColor(4)) w labels tc rgb var font ",17"
### end of code
结果:
一段时间以来我一直在处理这个文件的一些变种:
$DATA << EOD
0.910731391716549 0.0917930320554009 LABEL1 '#008000'
0.871162274545609 0.181191762678911 LABEL2 '#ffff00'
EOD
set key off
set border 3; set tics nomirror
set xrange [0:*]
plot "$DATA" using 1:2:3:4 with labels textcolor rgb variable
这是基于
应该制作一个散点图,标签为 LABEL1
和 LABEL2
但是当我 运行 GNUPlot gnuplot 5.2 patchlevel 8 我得到这个错误:
"/tmp/oBjdIStjpA" line 13: warning: Skipping data file with no valid points
plot "$DATA" using 1:2:3:4 with labels textcolor rgb variable
^
"/tmp/oBjdIStjpA" line 13: x range is invalid
这个错误毫无意义。
如果我将 plot
行更改为 plot "$DATA" using 1:2:3:4 with labels
GNUPlot 可以工作,但没有我想要的颜色。
我没有使用与其他发帖人相同的颜色编码,而且我不知道如何转换为其他发帖人使用的任何十进制编码。
如何获得每个点的颜色?
勾选help colorspec
。那里说 textcolor rgb variable
取数值(不是文本)。
因此,如果您将 '#008000'
和 '#ffff00'
更改为 0x008000
和 0xffff00
,它应该可以工作。
加法:
如果您不想更改原始数据,只需定义一个将字符串转换为整数的函数即可。
代码:
### string color variable to integer
reset session
$Data <<EOD
1 1 Label1 '#ff0000'
2 2 Label2 '#00ff00'
3 3 Label3 '#0000ff'
4 4 Label4 '#ff00ff'
5 5 Label5 '#ffff00'
6 6 Label6 '#00ffff'
EOD
unset key
set xrange [0:7]
set yrange [0:7]
myColor(col) = int('0x'.strcol(col)[3:])
plot $Data using 1:2:3:(myColor(4)) w labels tc rgb var font ",17"
### end of code
结果: