1
$\begingroup$

I am having trouble showing the entire y-axis for the given piece wise plot:

y[x_] := Piecewise[{{2, -2 <= x <= -1}, {1, -1 <= x <= 0}, {2, 
     0 <= x <= 1}, {3, 1 <= x <= 2}}];
Plot[y[x], {x, -2, 2}, AxesLabel -> {"t", "f_n(t)"}, 
 PlotRange -> Automatic]

I tried PlotRange Full, All or Automatic, but as you can see, the plot starts with y=1, and not y=0:

enter image description here

This is odd. How can I show the plot from y=0?

$\endgroup$

1 Answer 1

3
$\begingroup$

Manually specify that you want $y$-axis to begin at $0$.

Plot[y[x], {x, -2, 2}, AxesLabel -> {"t", "f_n(t)"}, 
 PlotRange -> {Automatic, {0, Automatic}}]
$\endgroup$
1
  • 1
    $\begingroup$ Or just PlotRange -> {0, Automatic} $\endgroup$
    – Bob Hanlon
    Apr 21, 2023 at 14:37

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.