Wednesday, January 25, 2012

High quality LaTeX figures using gnuplot - take 2

This is another way to make high quality figures for use in journal publications.  We will be using gnuplot and LaTaX to generate the figure.  Gnuplot will create an *.eps file that contains the image (lines and axes) and LaTeX will produce the text on the plot using the same font as the rest of your document, creating figures that look great.

Step 1: Create the image files using gnuplot

>> gnuplot
gnuplot>> set term epslatex
gnuplot>> set output "test_figure.tex"
gnuplot>> set xlabel '$\lambda_\theta$'
gnuplot>> set ylabel '$\omega - \mathrm{pi}$'
gnuplot>> set title 'This is a test'
gnuplot>> p sin(x) t 'sin(x)', cos(x) t 'cos(x)'
gnuplot>> exit
>>


Which should have made two files: test_figure.tex and test_figure.eps

Step 2: Compile figure in LaTeX document

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\centering
\input{test_figure.tex}
\end{figure}
\end{document}

This code can be compiled using pdflatex and will produce the following figure:

1 comment: