3
$\begingroup$

So, I got this code:

Plot[Piecewise[{{3, x <= 0}, {x^2 + 1, x > 0}}], {x, -2, 2}, 
 PlotStyle -> {Purple}, Axes -> False, Frame -> True]

and I want to add full dot at 0 from the left and partial at 0 from the right. I hope you know what I mean. Thank you.

$\endgroup$
2
2
$\begingroup$

Something like this?

f[x_] := Piecewise[{{3, x <= 0}, {x^2 + 1, x > 0}}]
rval = Limit[f[x], x -> 0, Direction -> -1];
Plot[
 f[x],
 {x, -2, 2},
 PlotStyle -> {Purple},
 Axes -> False,
 Frame -> True,
 Epilog -> {
   {PointSize[0.03], Purple, Point@{0, f[0]}},
   {PointSize[0.03], Purple, Point@{0, rval}},
   {White, PointSize[0.02], Point@{0, rval}}
 }
]

enter image description here

$\endgroup$
4
$\begingroup$

You can construct the desired marker using Disk and Circle:

halfdisk[color1_, color2_: White] := {Thickness[0.1], 
   EdgeForm[color1], color2,  Disk[{0, 0}, 1],
   color1, Disk[{0, 0}, 1, {π/2, -(π/2)}], Circle[{0, 0}]};

and use it with Inset as Epilog option in Plot:

epilog = {Inset[Graphics@halfdisk[Purple, Purple], {0, 1}, Automatic, Scaled[.05]],
      Inset[Graphics@halfdisk[Purple], {0, 3}, Automatic, Scaled[.05]]};

Plot[Piecewise[{{3, x <= 0}, {x^2 + 1, x > 0}}], {x, -2, 2}, 
  PlotStyle -> Purple, Axes -> False, Frame -> True, 
  Epilog -> epilog]

enter image description here

$\endgroup$
0
$\begingroup$
fn = Piecewise[{{3, x <= 0}, {x^2 + 1, x > 0}}];

p1 = Plot[fn, {x, -2, 2}, PlotStyle -> {Purple}, Axes -> False, Frame -> True];

p2 = ListPlot[{{0, Limit[fn, x -> 0, Direction -> #]}} & /@ {1, -1}, PlotStyle -> Purple,
     PlotMarkers -> (Graphics[#, ImageSize -> 10] & /@ {Disk[{0, 0}, 1], DiskSegment[{0, 0}, 1, {Pi/2, 3 Pi/2}]} )];

Show[p1, p2]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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