Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gnuplot - how to get colored text in label with epslatex terminal

I have a complex figure made with an epslatex terminal in gnuplot. It is a multiplot figure with four panels. In each panel I draw three curves (for three different values of a parameter) and then I superimpose another curve for another parameter on top of each curve. I can distinguish the first parameter with different types of points, and the second one with color.

So, I use the key to distinguish the different points and I would need to have another kind of key for the two colors. Then I use a label with colored text. The point is, the text does not get colored in the epslatex terminal!

I have

set terminal epslatex color solid 8

and

set label 10 'H' tc lt 1 at 0.01,6

This way I get the 'H' label in black. If I use

set terminal epslatex color colortext solid 8

it gives me the error

Package color not loaded in conjunction with terminal option `colourtext'.

Any idea what's the problem?

like image 786
mar tin Avatar asked Jul 11 '13 12:07

mar tin


2 Answers

You can use the \texcolor command, provided by color package. If you use standalone mode color package is automatically loaded with color option to terminal, otherwise you have to explicitly load color (or xcolor) package in your LaTeX document.

A colorful example:

set terminal epslatex color solid 8 standalone
set output "foo.tex"
set format x '$\textcolor{green}{%g}$'
set format y '$\textcolor{yellow}{%g}$'
set label 10 '\textcolor{blue}{H}' at 0.01,6
plot x**3 title '$\textcolor{magenta}{x}^{\textcolor{cyan}{3}}$'
set output

Result:

enter image description here

like image 122
giordano Avatar answered Nov 17 '22 01:11

giordano


Using the colortext option works, but as the error message says, you must include the color package in your document. If you use the standalone option, this is done automatically. So the following works fine:

set terminal epslatex color colortext standalone
set output 'foo.tex'
set label 'lt 1' tc lt 1 at graph 0.2,0.5
set label 'blue' tc rgb 'blue' at graph 0.7,0.5
plot x

There is no need to use the \textcolor macro explicitely unless you want different colors in one label.

like image 4
Christoph Avatar answered Nov 17 '22 00:11

Christoph