2
$\begingroup$

I've had this issue for quite awhile - and it's quite frustrating. When publishing papers, we try to get all of our figures in .pdf for obvious reasons. Usually, Mathematica exports to .pdf just fine, except when you have plots in a Row[]. For example:

testplot=Row[{
Plot[Sin[x], {x, 0, 2 \[Pi]}, Frame -> True, 
        FrameLabel -> {"y", "x"}, ImagePadding -> {{100, 0}, {100, 0}}, 
        BaseStyle -> {FontSize -> 30, FontFamily -> "Times"}, 
        LabelStyle -> Black, ImageSize -> 900],

   Plot[Cos[x], {x, 0, 2 \[Pi]}, Frame -> True, 
    FrameLabel -> {"y", "x"}, ImagePadding -> {{0, 1}, {100, 0}}, 
    BaseStyle -> {FontSize -> 30, FontFamily -> "Times"}, 
    LabelStyle -> Black, ImageSize -> 800]
   }]

Export["~/Desktop/test.pdf", testplot]
Export["~/Desktop/test.png", testplot]

Should produce a nice side-by-side plot, where each plot uses the same y-axis. The .png output looks fine:

Test .png output

While the .pdf output messes up and wraps the second plot:

messed up .pdf output

Has anyone seen this issue before? I've tried everything I can think of, but .pdf export just will not export side-by-side images!

Thanks in advance, Zack

$\endgroup$
  • 2
    $\begingroup$ Does GraphicsRow not work? $\endgroup$ – That Gravity Guy Oct 12 '18 at 22:15
  • $\begingroup$ When you export to PDF, your image width specify printers points at 72 per inch. If you want to put two figures side by side, set their widths to 216 each. $\endgroup$ – Alan Oct 13 '18 at 0:44
5
$\begingroup$

You could use a Style wrapper to prevent line breaks:

Export["pdftest.pdf", Style[testplot, LineBreakWithin->False]];
$\endgroup$
  • $\begingroup$ Thank you Carl!! $\endgroup$ – zack Oct 13 '18 at 3:03

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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