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?

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

  • 7
    $\begingroup$ Add the option PlotRangePadding -> 0? $\endgroup$
    – David Park
    Aug 15 '13 at 15:56
  • $\begingroup$ @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. $\endgroup$
    – Yves Klett
    Aug 15 '13 at 16:00
  • $\begingroup$ @DavidPark Great. Thanks! $\endgroup$
    – JACKY Li
    Aug 15 '13 at 16:06
  • 1
    $\begingroup$ This is one of those "easy to find in documentetion" issues but if you now what to look for :) $\endgroup$
    – Kuba
    Aug 15 '13 at 16:24

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], 

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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