Emily
Emily

Reputation: 31

Gnuplot line and key colors

I'm trying to use Gnuplot to create a line chart. Each line is represented by a different color. What I want is the key has the same color as the line color. This is what I have right now, current version. Is it possible to set the text 'Line 2' colored as orange, 'Line 3' colored as red, etc?

This is what I wrote in the gp file:

set xlabel'x-axis'; \
set xrange[0:25];\
set ylabel 'y-axis';\
set yrange [2:9];\
set key left top;
p   'test.dat' using 1:2 w linespoints lw 5 lc rgb '#aadc32' pt 17 title 'Line 1' ,\    
'test.dat' using 1:9 w linespoints lw 5 lc 'orange' lt 1 title 'Line 2',\
'test.dat' using 1:6 w linespoints lw 5 lc 'red' lt 8 title 'Line 3',\
'test.dat' using 1:7 w linespoints lw 5 lc 'violet' pt 6 title 'Line 4',\'test.dat' using 1:8 w linespoints lw 5 lc rgb '#b5367a' pt 19 title 'Line 5',\
'test.dat' using 1:3 w linespoints lw 5 lc 'cyan' pt 9 title'Line 6',\
'test.dat' using 1:4 w linespoints lw 5 lc 'blue' lt 9 title 'Line 7',\
'test.dat' using 1:10 w linespoints lw 5 lc rgb '#1c1044' lt 5 title 'Line 8',\

Thank you so much.

Upvotes: 3

Views: 3411

Answers (1)

Karl
Karl

Reputation: 2187

Unfortunately not. The plot title does not (now, gp5.2pl0) recognise the "textcolor" specifier.

plot x lw 3 lc rgb "blue" title "x" tc rgb "blue" # doesn't work

You can only print an empty (" ") plot title, and overprint it with a coloured label

set label 1 at 8,1 "bluetitle" tc rgb "blue"

That requires some fiddling with the placement of the label, of course.

You might put up a feature request on https://sourceforge.net/p/gnuplot/feature-requests/

Upvotes: 4

Related Questions