Hi, I’m intending to plot a piecewise fuction. The horizontol lines displays correctly.
How can I plot the vertical line connecting 20 and -60 @ x=6 and -60to0 at X=8
g[x_] := \[Piecewise] {
{20, x < 6},
{-60, 6 < x < 8},
{0, True}
}
Plot[g[x], {x, 0, 10}]
Strange.
I tried the same code from a different machine and now it displays the verticle lines as expected.
bobf
(Bob Freeman)
December 8, 2014, 3:39am
3
I tried this on Mathematica 8.0.4 on a Mac and it shows the same problem (missing vertical lines at x={60,80} also.
What version and OS did you have your problem and successes on?
You can try giving explicit Exclusions:
Plot[g[x], {x, 0, 10}, Exclusions -> {x == 6, x == 8},
ExclusionsStyle -> Red]
On my system (Mma version 10) I get the vertical lines also with this:
Plot[g[x], {x, 0, 10}, ExclusionsStyle -> Red]
sghuisman
(Sander Huisman)
December 8, 2014, 5:50pm
5
Just add the option to the plot:
Exclusions → None
sblinder
(S M Blinder)
December 8, 2014, 6:10pm
6
g[x_] := [Piecewise]{{20, x < 6}, {-60, 6 < x < 8}, {0, True}}
Plot[g[x], {x, 0, 10}, Exclusions -> None]