Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have plot generated by Plot[] function that I want to export to pdf file. The problem is that Export[] function somehow cuts a tiny bit of plot on the left side which results in something like this: Exported image

I'd like to know what should I do to get exported file without cropped $0$.

share|improve this question
3  
It's always best if you provide an example of the code you used. But even without that, I would suggest manually setting the Plot option ImagePadding -> 70 (or use a larger number). –  Jens Jun 22 '12 at 17:20
    
@Jens thanks, that works good. –  qoqosz Jun 22 '12 at 17:25
add comment

2 Answers

up vote 4 down vote accepted

Here is my original suggestion using ImagePadding:

p = Plot[Cos[x], {x, 0, 2}, AxesStyle -> Arrowheads[.1], 
  PlotRange -> {0, 1}, TicksStyle -> Large, RotateLabel -> False, 
  ImagePadding -> 70]

imagemargins

And here is an example of how to use ImageMargins in the plot command:

p = Plot[Cos[x], {x, 0, 2}, AxesStyle -> Arrowheads[.1], 
  PlotRange -> {0, 1}, TicksStyle -> Large, RotateLabel -> False, 
  ImageMargins -> 70]

Both methods work to give you extra space around the image. But I see Mr. Wizard just now explained this already.

Edit: a note for completeness

In a related question, one can see that neither ImagePadding nor ImageMargins work in some situations. Here is an example where Epilog is used to place a text below a plot:

Plot[Sin[x], {x, 0, 2 Pi}, 
 Epilog -> {Text["Show me the text", {Pi, -1.3}]}]

The text is not shown because it falls outside the PlotRange. When this happens, you can fix the problem by using PlotRangePadding:

Plot[Sin[x], {x, 0, 2 Pi}, 
 Epilog -> {Text["Show me the text", {Pi, -1.3}]}, 
 PlotRangePadding -> .5]

plot with epilog

share|improve this answer
    
I reduced my answer to this after realizing I was confusing ImagePadding and ImageMargins. –  Mr.Wizard Jun 22 '12 at 17:32
    
@Mr.Wizard Now you confuse me because I was editing while you were too... Hopefully all the bases are covered now. –  Jens Jun 22 '12 at 17:34
    
Jens, sorry, if I had been thinking clearly about ImageMargins/ImagPadding from the start I would have not have had to make a series of edits. –  Mr.Wizard Jun 22 '12 at 17:39
    
That's OK - you got my +1. –  Jens Jun 22 '12 at 17:40
add comment

Please try adding some space around the plot:

Plot[2 Sin[x] + x, {x, 0, 15}, Filling -> Bottom, ImageMargins -> 10]

ImageMargins gives a margin around the existing plot that can be seen by selecting the graphic (the outer orange frame):

enter image description here

By comparison ImagePadding is used by Plot itself to make room for the axes labels (the inner orange frame).

share|improve this answer
    
Thanks, but proposed ImagePadding option works good and is sufficient for my needs. –  qoqosz Jun 22 '12 at 17:27
    
@qoqosz actually I didn't see that comment above, and also I was confusing ImageMargins with ImagePadding; you can use ImageMargins directly in Plot and that would be a good method because you can use a small fixed value without cutting of the labels, as you would with ImagePadding. –  Mr.Wizard Jun 22 '12 at 17:30
    
Ok, good to know :) –  qoqosz Jun 22 '12 at 17:31
add comment

Your Answer

 
discard

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.