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)

mrchance
  • 1,133
  • 8
  • 24

1 Answers1

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

Ethan
  • 13,715
  • 2
  • 12
  • 21
  • thx a million ethan. somehow on my system (mac os) i dont get any coloring. so i must be missing some trivial thing... – mrchance Dec 03 '20 at 20:31
  • to ethans code, i applied '''(hex2rgbvalue(stringcolumn(4)))''' to the color column and got the expected result, see code for hex2rgbvalue here: http://gnuplot-surprising.blogspot.com/2012/08/converting-from-hex-string-color-to-its.html and i ALSO prepended "#" to the color entries (not enuff by itself though) – mrchance Dec 04 '20 at 00:26
  • You can do it a little easier with `(int("0x".strcol(4))) ` for your original data. – binzo Dec 04 '20 at 03:28