Journals usually ask for the figures in a publication to be in some specific formats (e.g. eps, svg, tiff etc). Now that I have used pgfplots to make all the figures in my article, what is the best course of action to convert all of the figures to e.g. eps? Should I use some kind of an external tool to extract all the figures (gpdfx, inkscape etc) from the current article and the convert them to the correct format, and then use \includegraphics
to include them again? A lot of tedious work, surely there is a better option?
2 Answers
Actually, thanks to percusse's comment, I researched the pgfplots' externalize
library and found that adding these two lines
\usepgfplotslibrary{external}
\tikzexternalize
to my preamble did just what I wanted for no effort at all!
(Ryan's answer is also great, and thanks to him, but this is a better way.)
One possible workflow would be to drop each pgfplots
figure or tikzpicture
: into a standalone
document, which would give you a .pdf
file of just that figure, which you could then convert using something else.
\documentclass{standalone}
\usepackage{pgfplotstable}
\pgfplotstableread{
Ma Mb a
200 50 5.6
170 80 3.3
140 110 1.0
100 150 -1.6
70 180 -3.9
}\caseone
\begin{document}
\begin{tikzpicture}
\begin{axis}[
title=Variable Net Force,
xlabel={Acceleration},
ylabel={Net Force},
legend entries={Raw Data,Line of Best Fit},
legend style={at={(0.973,0.03)},anchor=south east},
width=\textwidth,]
\addplot
[only marks, black]
table[x=Ma, y=a]{\caseone};
\addplot
[smooth, black, very thin]
table[x=Ma, y={create col/linear regression={y=a}}]
{\caseone};
\end{axis}
\end{tikzpicture}
\end{document}
The above would output just the plot in pdf
format, which then can be converted to anything and including it with \includegraphics
would work fine because the whitespace is trimmed.
If you're on a unix-like system you could then use ImageMagick Convert to convert all the images at once, for example if you named all your figures figure1.pdf
figure2.pdf
figure3.pdf
then you could use convert -density 600 figure*.pdf figure*.eps
to batch-convert them all, preserving numbering.
externalize
library specifically designed for this purpose.