4
$\begingroup$

I generated a plot in Mathematica and I wanted to use it in a paper, so I need it in EPS format, but when I save the picture as EPS, the plot is changed (font change, the picture that I add to plot did not show at the same position,...).

I attach the same plot saved as JPG, and the result of exporting from the EPS format. What should I do to fix this problem?

enter image description here enter image description here

$\endgroup$
  • 1
    $\begingroup$ Try using Export to save the image (not the GUI), and do not set an ImageSize. What do you get? Also try exporting to PDF, which is more reliable, and can still be converted to EPS. $\endgroup$ – Szabolcs Feb 21 '17 at 15:17
  • 1
    $\begingroup$ Here's my take, as someone who had to make countless figures for papers, all in EPS format, and all the plots made with Mathematica. 1) Make plot in Mathematica 2) Export plot as a PNG file 3) Import PNG into Inkscape 4) add text, labeling, whatnot to the Inkscape-native SVG file 5) Export SVG file. Sounds like a lot of work, but much less headache $\endgroup$ – Jason B. Feb 21 '17 at 15:18
  • 1
    $\begingroup$ @JasonB. I also use a similar workflow, but I export SVG files from Mathematica to edit with Inkscape, which keeps everything nice and vector-y; why the PNG step? $\endgroup$ – MarcoB Feb 21 '17 at 16:35
  • 1
    $\begingroup$ @JasonB. Yep, I totally agree: arrows, floating text/graphical annotations are A LOT easier to add in a WYSIWYG environment like Inkscape, where you just draw them in exactly where you want them. Not only that, but for 2D graphics where the SVG export works well, even formatting of axes, ticks, etc can sometimes be done MUCH more quickly after the fact rather than fighting MMA every step of the way. $\endgroup$ – MarcoB Feb 21 '17 at 16:52
  • 1
    $\begingroup$ Try setting SetOptions[$FrontEnd, PrintingStyleEnvironment -> "Working"] and then use Export for producing EPS. Explanations are here: mathematica.stackexchange.com/a/137746/280 $\endgroup$ – Alexey Popkov Feb 21 '17 at 17:44
3
$\begingroup$

May be this is also an option for you. I assume you want to have specific characters or fonts (defined in your paper with Latex-commands) in your plot, and that is the reason you want an eps-figure. I usually use the \psfrag in the Latex code.

1) Create your plot (plot1) in Mathematica as you like it

2) Create a preparated version for editing in Latex (plot2)

plot1 = Plot[Sin[x], {x, 0, Pi}, BaseStyle -> 15]
plot2 = Show[plot1, AxesLabel -> {aa, b}, PlotLabel -> "title", 
  Epilog -> {
    Text["t1", {Pi/2, 0.3}]
    , Inset[
     Graphics3D[Cylinder[], Boxed -> False, ImageSize -> 50], {1, 0.4}]
    , Inset[
     Graphics3D[{Yellow, Opacity[0.8], 
       PolyhedronData["TruncatedIcosahedron", "Faces"]}, 
      ImageSize -> 50], {2.5, 0.4}]
    }]
Export[NotebookDirectory[] <> "plot.eps", plot2];

enter image description here

3) Use \psfrag in your Latex document for automated editing (careful, Latex code incoming)

\documentclass{article}
\usepackage{graphicx}
\usepackage{psfrag}

\begin{document}
\title{Working with EPS-figures from Mathematica}
\author{Mauricio Lobos}
\maketitle
Bla bla bla
\begin{figure}[h]
\centering
\psfrag{aa}{$x$}
\psfrag{b}{$y$}
\psfrag{t1}{Some text}
\psfrag{title}{\hspace{-10mm}Some nice title}
\includegraphics[width=0.5\textwidth]{plot.eps}
\caption{EPS-figure form Mathematica}
\end{figure}
\end{document}

enter image description here

enter image description here

As you can see, with \psfrag I edited in the eps-figure the preparated labels on the axes (aa and b) so you can see the nice $x$ and $y$, a positioned text (t1) with "Some text" and the plot label (title) with "Some nice title". Naturally, you will have to move some things around in the Latex code (see \hspace{-10mm}). Some 3D primitives will stay sharp (vector graphics), as you can see in the balck edge of the cylinder, but other (like the transparent polyhedron) will be converted automatically by the export in Mathematica into pixel graphics within the eps figure.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.