4
$\begingroup$

Consider

Plot[Floor[x],{x,-5.5,5.5},ExclusionsStyle->{None,Blue}]

At each discontinuity, we get circles indicating the jump. Mathematically, Floor[x]=x at these discontinuities, which concides with the left part of the plot and not the right part. This is often indicated by the lower circle being solid and the upper circle being hollow. Can this check (does the boundary coincide with the left or right part) be performed automatically for each continuity, and manifest in the exclusions? For this example, it would appear something like

DiscretePlot[x,{x,-5,5},PlotRange->{-5.5,5.5},Filling->None,ExtentSize->Full,
  ExtentMarkers->{Graphics[{Thickness[.2],Circle[]}],"Point"}]

Effectively, the issue is that ExclusionsStyle doesn't distinguish between left and right sides of the jump (as DiscretePlot does), and it also doesn't allow for computation (as DiscretePlot doesn't).

$\endgroup$

1 Answer 1

6
$\begingroup$

1. We can post-process Plot output to replace vertical exclusion lines with disks with desired colors:

ClearAll[modifyExclusions]
modifyExclusions[colors_ : {Red, White}, radius_ : 3] := 
   ReplaceAll[Line[a : {_, _}] :> {EdgeForm[Gray], Opacity[1], 
       Riffle[colors, Disk[#, Offset[radius]] & /@ a]}]

Examples:

modifyExclusions[] @
  Plot[Floor[x], {x, -5.5, 5.5}, ExclusionsStyle -> {Red, None}]   

enter image description here

modifyExclusions[] @
  Plot[Floor[x], {x, -5.5, 5.5}, 
  ExclusionsStyle -> {Red, None}, Filling -> Axis] 

enter image description here

modifyExclusions[{Green, White}, 5]@
  Plot[Ceiling[x] Sin[x]/4, {x, 0, 3 Pi}, ImageSize -> Large, 
    ExclusionsStyle -> {Red, None}] 

enter image description here

modifyExclusions[{Green, White}, 5] @
 Plot[Ceiling[x] Sin[x]/4, {x, 0, 3 Pi}, ImageSize -> Large, 
  ExclusionsStyle -> {Red, None},  
  Filling -> Axis, FillingStyle -> LightOrange]

enter image description here

2. If we do not use the Filling option, a more convenient alternative is to use an undocumented feature of ExclusionsStyle and specify the option setting as a function:

ClearAll[exclusionsStyle]
exclusionsStyle[colors_ : {Red, White}, radius_ : 5] := {EdgeForm[Gray],  
  Riffle[colors, Disk[#, Offset[radius]] & /@ First[#]]}&

Examples:

Plot[Floor[x], {x, -5.5, 5.5}, 
  ExclusionsStyle -> {exclusionsStyle[], None} ]

enter image description here

Plot[Ceiling[x] Sin[x]/4, {x, 0, 3 Pi}, ImageSize -> Large, 
  ExclusionsStyle -> {exclusionsStyle[], None} ] 

enter image description here

$\endgroup$
1
  • $\begingroup$ Freaking awesome! Both filling=True and the undocumented ExclusionsStyle are a little buggy (second to last example on my system does not render dots, last one doesn't evaluate second function at all, ver 12.1). Not a problem though -- this is still very useful and usable. $\endgroup$
    – Adam
    Jun 4, 2021 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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