Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Welcome to Mathematica on Stack Exchange. May I suggest you include your actual data so we can assess the situation? – DavidC Mar 14 '12 at 8:39
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. – Sjoerd C. de Vries Mar 14 '12 at 9:14
Another syntax error in your code: you should have Export["test.pdf",g3, ImageResolution->600] – kglr Mar 14 '12 at 9:30
The syntax errors are because I was rertyping the code from my laptop to my desktop. Sorry. Please ignore them. – Henry B Mar 14 '12 at 14:31
@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. – Henry B Mar 14 '12 at 14:35
up vote 4 down vote accepted

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.

share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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