Most output terminals of gnuplot
draw different lines in a plot in different colors.
I'm trying to create a plot inside my PDF document using gnuplot
's LaTeX terminal and the lines are only distinguishable by linestyle.
What do I need to do to get the lines colored?
I use pdflatex
.
From this example:
\documentclass{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[miktex]{gnuplottex}
\usepackage{graphicx}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{gnuplot}[terminal=latex]
plot [0:2*pi] sin(x) title 'Sine', cos(x) title 'Cosine'
\end{gnuplot}
\end{figure}
\end{document}
I get this result:
@texenthusiast provides part of the solution: set the options [terminal=epslatex,terminaloptions=color]
when using gnuplot
.
And don't forget to load epstopdf
in your preamble:
\usepackage{epstopdf}
The lines in the plot will now be colored but still have different styles.
To give them the same style you can now use something like
set style line 1 linecolor rgb '#0060ad' linetype 1 linewidth 2
set style line 2 linecolor rgb '#dd181f' linetype 1 linewidth 2
plot [0:2*pi] sin(x) with lines ls 1 title 'Sine', cos(x) with lines ls 2 title 'Cosine'
Best Answer
Out of the many(
latex
,tex
,epslatex
,pstricks
pdf
andlua/tikz
)gnuplot
terminal exports availableepslatex
seems reasonable.Using
[terminal=epslatex,terminaloptions=color]
seems to be optimal since.eps
plot is taken fromgnuplot
andTeX
is used to typesettext in labels/titles
to give nice consistency. But for more options gnuplottex might give details.Example: How to draw a square wave?