I am trying to use Show to combine two plots so I do the following:

g1 = Plot[x, {0, 100}, AspectRatio -> 1]
g2 = ListContourPlot[data, FrameLabel -> {"label1", "label2"}, 
  PlotLabel -> "title", AspectRatio -> 1, 
  DataRange -> {{0, 100}, {0, 100}}]

g3 = Show[{g1, g2}]

Everything looks great on the computer.

Now, I want to export.

Export[g3, "test.pdf", ImageResolution -> 600]

This creates a problem. The y-axis label is completely missing. The image is cut off on the left-hand side. It's not white space or anything like that. It's just not there. The whole left side of the image is missing. The title of the plot is partially cut off too.

How do I fix this?

  • $\begingroup$ Welcome to Mathematica on Stack Exchange. May I suggest you include your actual data so we can assess the situation? $\endgroup$
    – DavidC
    Mar 14, 2012 at 8:39
  • 1
    $\begingroup$ Please note that your first plot specification contains a syntax error. I could edit Plot[x,{0,100},AspectRatio->1] to Plot[x,{x,0,100},AspectRatio->1] (x added in the plot range), but I'm not sure whether this is what you wanted to plot. $\endgroup$ Mar 14, 2012 at 9:14
  • $\begingroup$ Another syntax error in your code: you should have Export["test.pdf",g3, ImageResolution->600] $\endgroup$
    – kglr
    Mar 14, 2012 at 9:30
  • $\begingroup$ The syntax errors are because I was rertyping the code from my laptop to my desktop. Sorry. Please ignore them. $\endgroup$
    – Henry B
    Mar 14, 2012 at 14:31
  • $\begingroup$ @David Carraher: My data is several thousand points which makes it hard to post here; and also it's unpublished work by another person. I can't post it for confidentiality reasons. $\endgroup$
    – Henry B
    Mar 14, 2012 at 14:35

2 Answers 2


If you fix the syntax errors in Plot and Export, and change the ordering of the two graphics in Show everything works fine. The source of problem you are having is: Show uses the options from the first graphics object, and automatic values of image padding for your g1 does not leave space for the frame labels of g2 to show. So, the following minor changes in your code should fix the problem.

  g1 = Plot[x, {x, 0, 100}, AspectRatio -> 1] ;

  g2 = ListContourPlot[data, FrameLabel -> {"label1", "label2"}, 
  PlotLabel -> "title", AspectRatio -> 1, 
  DataRange -> {{0, 100}, {0, 100}}] ;

  g3 = Show[{g2, g1}]

  Export["test.pdf", g3, ImageResolution -> 600]

produces the correct pdf file that shows the frame labels.


Everything looks great on the computer.

Not quite... With Show[{g1,g2}] you get the following on the screen:



 data = RandomReal[{0, 10}, {20, 2}];

is used as data input for ListContourPlot.

Using Show[{g2,g1}] you get:

enter image description here

Finally, although the resulting pdf file shows the plot and frame labels

pdf export file

you probably still want to play with various values for ImagePadding as Szabolcs suggests to adjust the spaces on the four sides of the graph.


I was having a similar issue. While kguler provided the necessary information. The simplest fix may be at the bottom of his message -thus might not be read. I found that using the ImagePadding command provided the most direct results.

   ImagePadding -> {{Automatic, 10}, {Automatic, 10}}

The value of 10 can be adjusted as needed for your graph and labels.

I also find this helpful when I have a framed plot and want a small amount of whitespace outside the frame, so it is visually clear that all frame borders are the same size.


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.