无法在GNUPlot中获取要上色的标签
我已经使用了一些不同的文件有一段时间了:无法在GNUPlot中获取要上色的标签,gnuplot,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
$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
这个错误毫无意义
如果我使用带有标签的1:2:3:4将plot
行更改为plot“$DATA”,GNUPlot可以工作,但没有我想要的颜色
我没有使用与另一张海报相同的颜色编码,我不知道如何转换为另一张海报使用的十进制编码
如何获取每个点的颜色?检查帮助colorspec
。上面写着textcolor rgb变量
取数值(不是文本)
因此,如果您将'#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
如果不想更改原始数据,只需定义一个函数,将字符串转换为整数
代码:
### 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这是一段非常棒的代码,它也可以与splot
一起使用,非常感谢!