1

i have a file with 4 columns (x value), (y value), (label), (rgb color)

for example

1 43.3 JOHN 034143
2 11.6 BRIAN 987654
3 85.2 JOHN 034143
4 72.7 ALEX 765342
5 4.9 PETER 876897
6 42.7 ALEX 765342

i would like to plot each label on the corresponding position (x,y) with the corresponding color.

for example

have JOHN be printed at coordinate (1, 43.3) with rgb-color 034143
and have BRIAN be printed at coordinate (2, 11.6) with rgb-color 987654
and have JOHN be printed at coordinate (3, 85.2) with rgb-color 034143
and ...

to be sure, i would also like the labels to be printed vertically (rotated 90 deg) :-)

how may i achieve this?

(unfortunately and admittedly, im too dummy to extract/synthesize the exact answer from other similar questions or from the official documentation)

1 Answer 1

1

Assuming your color values are decimal numbers (rather than hex):

$DATA << EOD
1 43.3 JOHN 034143
2 11.6 BRIAN 987654
3 85.2 JOHN 034143
4 72.7 ALEX 765342
5 4.9 PETER 876897
6 42.7 ALEX 765342
EOD
set border 3; set tics nomirror
set xrange [0:*]   

plot $DATA using 1:2:3:4 with labels textcolor rgb variable rotate by 90

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

thx a million ethan. somehow on my system (mac os) i dont get any coloring. so i must be missing some trivial thing...
to ethans code, i applied '''(hex2rgbvalue(stringcolumn(4)))''' to the color column and got the expected result, see code for hex2rgbvalue here: gnuplot-surprising.blogspot.com/2012/08/… and i ALSO prepended "#" to the color entries (not enuff by itself though)
You can do it a little easier with (int("0x".strcol(4))) for your original data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.