Bug introduced in 9.0 and persisting through 12.0 or later

! See at bottom the answer by Wolfram Research.

I am running Mathematica 10.3.

For test purposes I have used the following code:

plot = ListPlot[{{0.25, 0.25}, {0.5, 0.5}, {0.75, 0.75}}, 
   Frame -> True, PlotRange -> {{0, 1}, {0, 1}}, Joined -> True, 
   AspectRatio -> 1, 
   FrameLabel -> {{"y (mm)", ""}, {"x (mm)", 
   BaseStyle -> {FontWeight -> "Bold", FontSize -> 40, 
     FontFamily -> "Calibri"}, ImageSize -> 800];

Export["F:\\export23.png", plot, "png"];

The upper plot margin depends on the length of the 4th string of FrameLabel.

Here are two images for comparison with a string length of 22 and 23 characters. The red square area marks the additional margin which occurs for 23 character length and more.

enter image description here

This problem does not! occur when the images are saved directly from the notebook via "Save Graphic As ..."

What could be the reason?

Answer from Wolfram Research- Technical Support:

I have reproduced this problem where Export creates too much whitespace in your plot. I have filed a report with our developers so that they can look into the issue further and potentially fix it in some future version of Mathematica. Your contact information has been appended to the report so that you can be notified when this issue is fixed.

george2079 wrote: Edit: simple example. Make the label string longer than about 20 char and the margin grows (for no evident reason )

  ListPlot[{{0.25, 0.25}, {0.5, 0.5}, {0.75, 0.75}}, Frame -> True, 
   PlotRange -> {{0, 1}, {0, 1}},
   Joined -> True, AspectRatio -> 1, 
   FrameLabel -> {{"y (mm)", ""}, {"x (mm)", 
      StringJoin@RandomChoice[CharacterRange["a", "z"], 20]}},
   BaseStyle -> {FontWeight -> "Bold", FontSize -> 40, 
     FontFamily -> "Calibri"}, ImageSize -> 2000], "PNG"], "PNG"]
  • $\begingroup$ see if you can reproduce the issue without using dynamic. $\endgroup$
    – george2079
    Dec 1, 2015 at 18:45
  • $\begingroup$ I can reproduce, from what I can tell, it has to do with the length of the title- it seems to add padding when you get over n chars $\endgroup$ Dec 1, 2015 at 18:48
  • 1
    $\begingroup$ Including ImagePadding seems to work. Try adding ImagePadding -> {{All, All}, {All, 50}} $\endgroup$
    – Hubble07
    Dec 1, 2015 at 20:17
  • $\begingroup$ Looks like a bug, please report to WRI ([email protected]) $\endgroup$
    – M.R.
    Dec 1, 2015 at 20:47
  • $\begingroup$ indeed only the length is responsible for the increasing upper margin ... I am changing therefore my question $\endgroup$
    – mrz
    Dec 1, 2015 at 21:52

1 Answer 1


It is a bug introduced in version 9. A workaround is to export the corresponding Cell expression:

Export["export23.png", Cell@BoxData@ToBoxes[plot]]


An alternative is to use RawBoxes:

Export["export23.png", RawBoxes@ToBoxes[plot]]

... or ExpressionCell:

Export["export23.png", ExpressionCell[plot]]

Checked with versions 9.0.1 and 10.3.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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