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 want to set a zero offset for the frame origin. In other words, the horizontal axis should start at exactly the lower bound, instead of having a small offset.

For example, in the figure below, even though I set the range of x to be [0, 6], the x axis starts at a small negative value. What do I need to do to make the x axis start at exactly 0?

Needs["PlotLegends`"]
Plot[Sin[x], {x, 0, 6}, Frame -> True, FrameLabel -> {x, y}, 
 RotateLabel -> True, PlotLegend -> {"a=1"}, 
 LegendPosition -> {0.3, 0.3}, LegendSize -> 0.5, 
 LegendShadow -> None, LegendBorder -> None]

enter image description here

share|improve this question
5  
Add the option PlotRangePadding -> 0? –  David Park Aug 15 '13 at 15:56
    
@DavidPark even if the solution is trivial, it is useful, so why not post an answer? I would also not vote for closure, but that is subjective. –  Yves Klett Aug 15 '13 at 16:00
    
@DavidPark Great. Thanks! –  Patrick Li Aug 15 '13 at 16:06
    
This is one of those "easy to find in documentetion" issues but if you now what to look for :) –  Kuba Aug 15 '13 at 16:24
add comment

1 Answer

up vote 7 down vote accepted

This is just to illustrate that the PlotRange and the padding on the Frame are independent of the domain of the Plot function.

Plot[Sin[x], {x, -1, 10},
 PlotRange -> {{0, 2 \[Pi]}, {-1, 1}},
 PlotRangePadding -> 0,
 Frame -> True,
 FrameTicks -> {{Automatic, Automatic}, {Range[0, 2 \[Pi], \[Pi]/2], 
    Automatic}}]

enter image description here

share|improve this answer
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.