Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I have multiple colors in a gnuplot label?

Tags:

label

gnuplot

I have this graph in gnuplot:

enter image description here

I want to include totals for each of the three colored line graphs. One possibility is to replace the key with this:

enter image description here

Can I plot this with a single label that switches colors? If not then I'd have to use six labels. In that case, how do I determine the coordinates of the labels given that the widths of the strings can vary? I could use a fixed width font and do some computation based on the number of digits in each of the totals but this seems tedious.

Is there a more clever way to indicate totals in a graph?

like image 853
Sol Avatar asked Oct 31 '25 03:10

Sol


1 Answers

You can use enhanced text mode to overprint differently coloured labels:

set label 1 at 0,0 textcol rgb "red" "ONE"
set label 2 at 0,0 textcol rgb "blue" "&{ONE}TWO"
set label 3 at 0,0 textcol rgb "green" "&{ONETWO}THREE"

Any text that is inside the brackets in &{SPACE} is replaced by an empty space with the width of the text "SPACE".

In gp versions <5 you need to enable enhanced text mode first, it is by default since 5.0

update: set xtics works similar in principle, but you cannot set two labels a the same position, they replace each other, and the textcolor option is valid for the whole axis. So this doesn't work:

set xtics left ("ONE"  1) textcol rgb "red"
set xtics add ("&{ONE}TWO"  1.00001) textcol rgb "blue"
set xtics add ("&{ONETWO}THREE"  1.00002) textcol rgb "green"
like image 135
Karl Avatar answered Nov 03 '25 04:11

Karl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!