7

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?

4
  • 2
    tex.stackexchange.com/q/8641 or tex.stackexchange.com/q/91275 or tex.stackexchange.com/q/140796 or tex.stackexchange.com/q/91472 (please let me know, if one of these works for you)
    – LaRiFaRi
    Commented Nov 10, 2014 at 13:27
  • I'm sorry, but I believe none of them are very useful as I need to export all of the figures in one document into separate standalone files (pdf, eps or svg).
    – eimrek
    Commented Nov 10, 2014 at 18:11
  • 1
    Don't use .eps for the final format but pgfplots and TikZ have a full-blown externalize library specifically designed for this purpose.
    – percusse
    Commented Nov 11, 2014 at 8:19
  • 1
    I think that your question is exact duplicate of those questions introduced you by @LaRiFaRi
    – enthu
    Commented Nov 11, 2014 at 8:19

2 Answers 2

8

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.)

6

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .