Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set label and line the same color in gnuplot

Very simple stuff. I want a function, say function f, to be plotted with a particular color. I also want a piece of label saying "function f color" which is also displayed in that color.

I am trying this so far:

set style line 1 lw 3 lc 1
set label "AC" at 0, 70 textcolor 1

but apparently the "lc" and "textcolor" follows different specs, and it complains:

"trolo4.pl", line 8: colorspec option not recognized

any help would be great!

like image 435
Evan Pu Avatar asked Jun 27 '12 05:06

Evan Pu


2 Answers

Try this instead:

set label "AC" at 0, 70 textcolor linetype 1

or

set label "AC" at 0, 70 textcolor linespec 1

Read the manual in gnuplot> help label to learn more.

like image 90
holygeek Avatar answered Nov 08 '22 22:11

holygeek


The answer by @holygeek works fine. Coming from python, I find that it is often nice to be a little more explicit.

set style line 1 lw 1 lc rgb "red"
set label "AC" at 0, 70 tc rgb "red"

Note that the set of color names recognized by your gnuplot is system dependent (see show colornames for a complete list). To achieve complete system independence, you can use the #RRGGBB version. e.g. red is '#ff0000, green is #00ff00 and blue is #0000ff. of course, you can make up all sorts of interesting colors (again, see show colornames for a list of pre-defined colors and their equivalent #.....)

for more info, also see help colorspec

like image 38
mgilson Avatar answered Nov 09 '22 00:11

mgilson