A very common feature of graphs of functions used throughout textbooks are simple indications, such as open circles, of the points at which a function is undefined. Is there a way to do this in Mathematica?

I understand that I can use Epilog (or Prolog, or other explicit drawing graphics functions) to "manually" draw these elements, but us there a way to automatically do this, or at least return the coordinates of such points for use as arguments to Epilog?


By using Exclusions and ExclusionsStyle like this

Plot[1/Sin[π x], {x, -3, 3},
  Exclusions -> Sin[π x] == 0, 
  ExclusionsStyle -> {Thin, Directive[Red, PointSize[0.02]]}

you can define the location of the discontinuities and the style for poles and discontinuity boundaries, respectively.

Exclusionsstyle example image

Also the Wolfram Blog, March 2011 has more examples on this topic.

  • $\begingroup$ Why won't this work with Sin[x]/x, {x, -10, 10}, Exclusions -> {0}? $\endgroup$ – orome Jan 17 '12 at 21:46
  • $\begingroup$ actually, i don't know. But in this case you can get a more consistent result by specifying the points to be excluded by an implicit equation: Exclusions -> Sin[\[Pi] x]==0. I'll update the answer accordingly. $\endgroup$ – Thies Heidecke Jan 17 '12 at 21:56
  • 1
    $\begingroup$ @raxacoricofallapatorius: In that case I would use Exclusions->x == 0. $\endgroup$ – Mike Bailey Jan 18 '12 at 0:38
  • $\begingroup$ @raxacoricofallapatorius - note that an exclusion is not necessary if you use Sinc[x] rather than Sin[x]/x. $\endgroup$ – Bob Hanlon Feb 21 '15 at 18:18
  • $\begingroup$ @BobHanlon: Yes, but that's not the question. $\endgroup$ – orome Feb 21 '15 at 19:58

You can use the ExclusionsStyle option to control how Mathematica renders regions excluded from the Plot.

Edit Doing something like ExclusionsStyle -> {None, {{Black, PointSize[Large]}}} will put a large point at the excluded points. For example, modifying a function from the help documentation:

Mathematica graphics

  • $\begingroup$ As near as I can tell, that simply changes how that segment of the graph is drawn (e.g. by omitting a single pixel in the figure), and provides no way to "exaggerate" the relevant points so they can be clearly seen. $\endgroup$ – orome Jan 17 '12 at 21:36
  • $\begingroup$ I've updated with another option. The second entry in that options list sets the boundary style for the exclusion. $\endgroup$ – Eli Lansey Jan 17 '12 at 21:38

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.