Plot[1/(x^3 - 2 x^2), {x, -2, 4}, Exclusions -> True]

Plot[1/(x^3 - 2 x^2), {x, -2, 4}, Exclusions -> 2]


I cannot understand why I have to specify the position of discontinuity (2nd plot) in order to get rid of the vertical line at x=2 (which exists in the first plot). Exclusions->True is not for detect the position of discontinuities? The function is rather simple.

• Does plotting $\frac1{x-2}$ have the same problem? May 18 '15 at 14:34
• So, this is is considered a "normal" behavior? May 18 '15 at 14:42
• @Guesswhoitis., yes same problem with 1/(x-2). - dimitris, Here is the advice on how to do it from the docs (Plot > "Options" > "Exclusions"): Plot[1/(x^3 - x + 1), {x, -2, 2}, Exclusions -> {x^3 - x + 1 == 0}] May 18 '15 at 14:50
• @dimitris I think it doesn't try. I also think x == 0 is not excluded per se -- the plot just goes beyond the PlotRange and re-enters on the same side. It would be nice if Exclusions -> All would call NSolve or do something extra. It does not seem to. May 18 '15 at 15:17
• I think for Exclusions, the settings All and True are synonymous with Automatic. In the trace, foo = Trace[Plot[1/(x^3 - 2 x^2), {x, -2, 4}, Exclusions -> True], TraceInternal -> True];, this happens: If[GraphicsPerformanceTuningDumpexclusions === All || GraphicsPerformanceTuningDumpexclusions === True, GraphicsPerformanceTuningDumpexclusions = Automatic]. May 18 '15 at 15:40

Plot seems to only do exclusions automatically for certain functions, such as Piecewise and some functions with branch cuts. For algebraic functions it seems to require an equation be passed to the Exclusions options.

I suspect that Plot determines exclusions in the same way as mesh points, by tracking when a zero is crossed. It seems simple enough to make an equation that defines which points are to be excluded:

Plot[f, {x, a, b}, Exclusions -> {1/f == 0}]


If you like, you can put this in a wrapper:

ClearAll[addExcl];
addExcl[Plot[f_, {x_, a_, b_}, opts___?OptionQ]] :=
Plot[f, {x, a, b}, Exclusions -> Flatten@{Thread[1/f == 0]}, opts]


Examples:

addExcl@Plot[Tan[x]/(x^3 - 2 x^2), {x, -2, 4}] addExcl@Plot[{Tan[x]/(x^3 - 2 x^2), 1/(1 - Log[x])}, {x, -2, 4}] • @dimitris You're welcome. :) May 18 '15 at 15:41