2
$\begingroup$

I have some graphics with two plots per row. When I Export as pdf all the plots are in a column. I want to keep them in rows. Here is a minimum working example.

 is = 5 72;
    pp = Column[
      Table[{
        Row[{Plot[Sin[n t], {t, 0, 5 π}, ImageSize -> is, 
           PlotStyle -> Red], 
          Plot[Haversine[n t], {t, 0, 5 π}, ImageSize -> is, 
           PlotStyle -> Blue]}]
        }, {n, 5}]
      ]

Mathematica graphics

However following

Export["Fig.pdf", pp]

The pdf file has a plot that looks like

Mathematica graphics

This seems to be an issue with the image size. If I reduce the value of is above to 4*72 then I get my two columns but this is too small. I have also tried

SetOptions["stdout", PageWidth -> Infinity]

but this does not work. Any suggestion for methods that keep my rows. (Note my actual case is more complicated). Thanks

$\endgroup$
  • $\begingroup$ Works for me if I change Row to GraphicsRow. $\endgroup$ – MelaGo Apr 30 '19 at 21:01
  • $\begingroup$ Or just use Grid $\endgroup$ – M.R. May 1 '19 at 18:14
  • $\begingroup$ @MelaGo Thanks. This approach seems to put more space between my plots, but helps.. $\endgroup$ – Hugh May 1 '19 at 18:31
2
$\begingroup$

Here are three ways to fix this:

is = 5 72;
pp = Column[
   Table[Row[{Plot[Sin[n t], {t, 0, 5 \[Pi]}, ImageSize -> is, 
       PlotStyle -> Red], 
      Plot[Haversine[n t], {t, 0, 5 \[Pi]}, ImageSize -> is, 
       PlotStyle -> Blue]}], {n, 5}]];
pp1 = Grid[
   Table[{Plot[Sin[n t], {t, 0, 5 \[Pi]}, ImageSize -> is, 
      PlotStyle -> Red], 
     Plot[Haversine[n t], {t, 0, 5 \[Pi]}, ImageSize -> is, 
      PlotStyle -> Blue]}, {n, 5}]];
pp2 = Column[
   Table[GraphicsRow@{Plot[Sin[n t], {t, 0, 5 \[Pi]}, ImageSize -> is,
        PlotStyle -> Red], 
      Plot[Haversine[n t], {t, 0, 5 \[Pi]}, ImageSize -> is, 
       PlotStyle -> Blue]}, {n, 5}]];

GraphicsRow[{
  Thumbnail@
   First@Import@
     Export["~/Downloads/test.pdf", 
      Style[pp, LineBreakWithin -> False], "PDF"],
  Thumbnail@First@Import@Export["~/Downloads/test.pdf", pp1, "PDF"],
  Thumbnail@First@Import@Export["~/Downloads/test.pdf", pp2, "PDF"]
  }]

enter image description here

|improve this answer|||||
$\endgroup$
  • $\begingroup$ Thanks, I have some text which requires some aligning of plots. Grid and GraphicsRow upsets my layout. Your first solution works well in this case. $\endgroup$ – Hugh May 1 '19 at 18:42

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.