11
$\begingroup$

For example

f[x_] := (x^5 - 4 x^2 + 1)/(x - 1/2);
Plot[f[x], {x, -1, 2}, Exclusions -> {f[x] == 0}, ExclusionsStyle -> Dashed]

enter image description here

Has the ExclusionsStyle -> Dashed option done anything here?

$\endgroup$
  • $\begingroup$ From the votes I think it is clear that people appreciate your (re)posting this. :-) $\endgroup$ – Mr.Wizard Jul 18 '15 at 8:52
  • 2
    $\begingroup$ @Mr.Wizard I think this story told me that while it's important to be friendly to the new comers, it's equally important to place answers under appropriate questions :D $\endgroup$ – xzczd Jul 18 '15 at 12:53
13
$\begingroup$

Outwardly, the graph looks just the same as the one without ExclusionsStyle -> Dashed:

f[x_] := (x^5 - 4 x^2 + 1)/(x - 1/2);
g1 = Plot[f[x], {x, -1, 2}, Exclusions -> f[x] == 0]

enter image description here

But it's surprising that ExclusionsStyle does make a difference actually. Let's check the graphs with Alexey Popkov's shortInputForm:

g1 // shortInputForm

enter image description here

g2 = Plot[f[x], {x, -1, 2}, Exclusions -> f[x] == 0, ExclusionsStyle -> Dashed] 
g2 // shortInputForm

enter image description here

We can see that in both cases Exclusions breaks the curves at f[x] == 0, but when setting ExclusionsStyle -> Dashed, 3 very short dashed lines are created!

It'll be more interesting if you extend these lines with the InfiniteLine in v10:

Show[g2, Epilog -> {Red, PointSize@Medium, Point[{x, 0} /. NSolve[f[x], Reals]]}] /. 
Line[{a_, b_}] -> InfiniteLine[{a, b}]

enter image description here

The dashed lines seem to be tangent lines at those excluded points!

Let's check the slopes of the short lines:

Cases[g2, Line[{p1_, p2_}] :> (#2/# & @@ (# - #2) &[p1, p2]), Infinity] // Sort
(* {-449.031, -4.26733, 14.6531} *)

They're very close to the derivatives at the exclusive points:

f'[x] /. NSolve[f[x] == 0, x, Reals] // Sort
(* {-443.273, -4.26733, 14.6531} *)

Further check shows that the end points of the short lines are all on the curve:

Cases[g2, Line[{p1_, p2_}] :> (f@# - #2 & @@@ {p1, p2}), Infinity]
(* {{0., 0.}, {0., 0.}, {0., 0.}} *)

So the short lines are probably short secant lines near the exclusive points, which can be used as approximate tangent lines.

This is not the end of the analysis, m-goldberg's answer shows that the working mechanism of ExclusionsStyle is even more subtle than what I've represented in this answer, but since my original intention is just to demonstrate the interesting behavior above, I'd like to stop here at this moment.

| improve this answer | |
$\endgroup$
  • 2
    $\begingroup$ "seem to be" - to verify, check the slope of those lines, and compare with the value of the derivative at those exclusion points. $\endgroup$ – J. M.'s technical difficulties Jul 17 '15 at 11:18
  • $\begingroup$ @Guesswhoitis. Some more analyses added. (A little busy yesterday :) ) $\endgroup$ – xzczd Jul 18 '15 at 12:45
  • $\begingroup$ Yes, I was expecting them to be secants actually, but it's nice how close the slopes are. $\endgroup$ – J. M.'s technical difficulties Jul 18 '15 at 12:47
7
$\begingroup$

I think that I stated this before in a previous post: ExclusionsStyle is a rather strange option. It works differently than other style options and the documentation on it must be read carefully.

The relevant part of the documentation for this question is that concerning the style specification for the exclusion boundary points. In the OP's example, where the excluded regions are drawn as dashed lines, only a boundary point style specification will a strong visible effect on the exclusions generated by the plot in question. The dashed lines are too short to show up at the scale of the plot.

f[x_] := (x^5 - 4 x^2 + 1)/(x - 1/2);
Plot[f[x], {x, -1, 2}, 
  Exclusions -> f[x] == 0, ExclusionsStyle -> {Dashed, Red}] 

plot

Of course, the exclusion regions can be made visible. Here I do it in a rather gross way, just to make the point.

Plot[f[x], {x, -1, 2},
  Exclusions -> f[x] == 0, ExclusionsStyle -> {{Green, Thickness[.1]}, Red}]

gross

| improve this answer | |
$\endgroup$
  • $\begingroup$ Actually with ExclusionsStyle -> Directive[{Thickness[.01], Red}] we obtain similar effect. But +1, interesting. $\endgroup$ – Alexey Popkov Jul 17 '15 at 15:58
  • $\begingroup$ @AlexeyPopkov. You make a good point. I have edited my answer to make my point clearer and more relevant to the question. $\endgroup$ – m_goldberg Jul 17 '15 at 16:21
  • $\begingroup$ So the behavior of ExclusionsStyle is more subtle than I thought. It's worth mentioning that actually there're 8 red points on the graph. $\endgroup$ – xzczd Jul 18 '15 at 12:49

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.