Group Abstract Group Abstract

Message Boards Message Boards

0
|
789 Views
|
6 Replies
|
12 Total Likes
View groups...
Share
Share this post:
GROUPS:

How to modify the graph of a piecewise function correctly?

Posted 1 month ago
POSTED BY: Bill Blair
6 Replies
Posted 1 month ago

You can draw the vertical segments manually using Line and mark open/closed endpoints with Point inside a Graphics overlay. Show[Plot[...], Graphics[{...}]] gives you full control over those boundary details.

POSTED BY: Connor Hayes
Posted 1 month ago

Thank you for providing the code. The approach is neat and fully meets the requirements.

POSTED BY: Bill Blair
Posted 1 month ago

Adding the open circles:

f2[x_]:=E^Mod[x,2,-2]

Show[
  Plot[f2[x],{x,-6,4},ExclusionsStyle->Dashed,AxesOrigin->{0,0}],
  ListPlot[{{-4,1},{-2,1},{0,1},{2,1},{4,1}},PlotMarkers->"OpenMarkers"]
]
POSTED BY: Hans Milton

Here's a mod to Eric's approach to put circles at the right ends of the lines of the plot:

f2[x_] := E^Mod[x, 2, -2]
myplot = Plot[f2[x], {x, -6, 4}, ExclusionsStyle -> Dashed,
  PlotStyle -> 
   Directive[
    Arrowheads[{{0.01, 1, 
       Graphics[{White, EdgeForm[ColorData[101][1]], Disk[]}]}}]
    ]
  ] /. g : {___, Directive[___, _Arrowheads, ___], ___} :> (g /. Line -> Arrow)

It puts them at ALL the right end points, whether they deserve an open dot or not. You'll have to manually put some conditions in, if you want to restrict which segments get dots (e.g, the last one on the right should not get one if x were to go up to 4.5).

Or you could remove the last dot with the following:

myplot // With[{pos = Last@Position[#, _Arrow]}, 
   ReplacePart[#, pos -> (Extract[#, pos] /. Arrow -> Line)]
   ] &
POSTED BY: Michael Rogers
Posted 1 month ago

You can modify your function:

f2[x_] := E^Mod[x, 2, -2]

And then use ExclusionsStyle:

Plot[f2[x], {x, -6, 4}, ExclusionsStyle -> Dashed]

enter image description here

As for the circles, there might be other ways to use ExclusionsStyle or Exclusions, but I didn't see anything obvious.

POSTED BY: Eric Rimbey

I would suggest the option Exclusions, but it does not work with your style of defining functions. Do real Piecewise definitions instead, which are built for symbolic computation. As for the open circles, you can do them only manually, I suspect.

POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard