3
$\begingroup$

When using GraphicsGrid to make multiple plots, if one plot has a longer title, the sizing gets messed up when the image is exported to pdf. Below is a massively simplified example code,

gj0 = Plot[BesselJ[0, x], {x, 0, 10}, Frame -> True, 
FrameLabel -> {{Style["Label", Black, 17], 
  None}, {Style[" ", Black, 19], 
  Style["Longer than long Population Fraction 100 x 500", Black, 
   22]}}];
gy1 = Plot[BesselY[0, x], {x, 1, 10}, Frame -> True, 
FrameLabel -> {{Style[" ", Black, 17], 
  None}, {Style[" ", Black, 19], 
  Style["Population Fraction 100 x 500", Black, 22]}}];
gj2 = Plot[BesselJ[0, x], {x, 0, 10}, Frame -> True, 
FrameLabel -> {{Style["Label", Black, 17], 
  None}, {Style[
   "\[LeftAngleBracket]\!\(\*SubscriptBox[\(\[Theta]\), 
StyleBox[\"int\",\nFontSlant->\"Italic\"]]\)\[RightAngleBracket]", 
   Black, 19], 
  Style["Population Fraction 100 x 500", Black, 22]}}];
gy3 = Plot[BesselY[0, x], {x, 1, 10}, Frame -> True, 
FrameLabel -> {{Style[" ", Black, 17], 
  None}, {Style[
   "\[LeftAngleBracket]\!\(\*SubscriptBox[\(\[Theta]\), 
StyleBox[\"int\",\nFontSlant->\"Italic\"]]\)\[RightAngleBracket]", 
   Black, 19], 
  Style["Population Fraction 100 x 500", Black, 22]}}];

test = GraphicsGrid[{{gj0, gy1}, {gj2, gy3}}, Spacings -> {-20, 0}]

Export["~/Documents/Latex/figures/test.pdf", test, 
ImageSize -> {1800, 1075}]

Which results in the following image,

enter image description here

Which is interesting because in Mathematica the image looks just fine.

Also, if the title is shortened up, then it appears just fine as a pdf.

$\endgroup$
  • $\begingroup$ Not an answer to your question, but I wanted to mention to that I gave up on grid-layouts in figures a long time ago. It's possible to do it, but it is troublesome, and you can expect to run into difficulties like this from time to time. Now I use SciDraw exclusively for producing publications quality figures arranged in a grid. SciDraw is also a lot of work both to learn and to use, but it is at least reliable, and thus not frustrating. The reason why it's a lot of work to use is that it effectively forces to me to control every detail of the figure manually. $\endgroup$ – Szabolcs Sep 20 '18 at 8:34
  • $\begingroup$ But when I a producing publication figures, I would spend a lot of time on these details ayway, to make the result perfect. Thus in the end SciDraw is still a time saver for such work. For producing quick and dirty results to show at a meeting, SciDraw tends to be too much trouble. $\endgroup$ – Szabolcs Sep 20 '18 at 8:35

Your Answer

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

Browse other questions tagged or ask your own question.