I have this graph in gnuplot:

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

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?
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With