Reputation: 6123
I have been working with some variety of this file for a while:
$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
this is based on gnuplot scatter plot, labels with color
which should make a scatterplot, with labels LABEL1
and LABEL2
but when I run GNUPlot gnuplot 5.2 patchlevel 8 I get this error:
"/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
This error makes no sense.
If I change the plot
line to plot "$DATA" using 1:2:3:4 with labels
GNUPlot works, but without the colors that I want.
I'm not using the same color coding that the other poster did, and I don't know how to convert to whatever decimal coding that the other poster used.
How can I get colors for each point?
Upvotes: 1
Views: 237
Reputation: 26198
Check help colorspec
. There it says textcolor rgb variable
takes numerical values (not text).
So, if you change '#008000'
and '#ffff00'
to 0x008000
and 0xffff00
it should work.
Addition:
If you don't want to change your original data you simply define a function which converts the string into an integer number.
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
Result:
Upvotes: 1