12
$\begingroup$

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

$\endgroup$
4
  • 7
    $\begingroup$ Add the option PlotRangePadding -> 0? $\endgroup$
    – David Park
    Commented Aug 15, 2013 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
    Commented Aug 15, 2013 at 16:00
  • $\begingroup$ @DavidPark Great. Thanks! $\endgroup$
    – JACKY88
    Commented Aug 15, 2013 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
    Commented Aug 15, 2013 at 16:24

1 Answer 1

17
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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