繁体   English   中英

无法在 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

这是基于gnuplot scatter plot,带有颜色的标签

它应该制作一个散点图,带有标签LABEL1LABEL2但是当我运行 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

这个错误没有意义。

如果我使用带有标签 GNUPlot 的 1:2:3:4 将plot行更改为plot "$DATA" using 1:2:3:4 with labels工作,但没有我想要的 colors。

我没有使用与另一张海报相同的颜色编码,而且我不知道如何转换为另一张海报使用的任何十进制编码。

如何获得每个点的 colors?

检查help colorspec 那里说textcolor rgb variable采用数值(不是文本)。

因此,如果您将'#008000''#ffff00'更改为0x0080000xffff00它应该可以工作。

添加:

如果您不想更改原始数据,只需定义一个 function 即可将字符串转换为 integer 数字。

代码:

### 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

结果:

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM