Message Boards Message Boards

0
|
15557 Views
|
5 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Piecewise plot vertical line

Posted 11 years ago
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}]
POSTED BY: Rashmil D
5 Replies
Posted 11 years ago


Strange.
I tried the same code from a different machine and now it displays the verticle lines as expected. 
POSTED BY: Rashmil D
Posted 10 years ago

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.

enter image description here

What version and OS did you have your problem and successes on?

POSTED BY: Bob Freeman

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]
POSTED BY: Gianluca Gorni

Just add the option to the plot: Exclusions -> None

POSTED BY: Sander Huisman
g[x_] := \[Piecewise]{{20, x < 6}, {-60, 6 < x < 8}, {0, True}}


Plot[g[x], {x, 0, 10}, Exclusions -> None]
POSTED BY: S M Blinder
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract