I want to ContourPlot an expression over an interval that excludes some points. Since i dont know how to do it I wrote

ContourPlot[{((1 - Tanh[X])/(1 + Tanh[X]))^-k == (k + Tanh[X])/(k - Tanh[X]),((1 - Tanh[X])/(1 + Tanh[X]))^-k == -((k + Tanh[X])/(k - Tanh[X]))}, {X, -0.1, 5}, {k, -Sqrt[(3/2)], Sqrt[3/2]},PlotRange -> {{0, 5},Full}, FrameLabel -> {"\!\(\*FractionBox[\(\*SubscriptBox[\(m\),\(\\[Phi]\)] L\), SqrtBox[\(2\)]]\)", "k"},ContourStyle -> {Red, Blue}, PlotLegends -> {"+sign", "-sign"}]

and obtained

enter image description here

But I want to plot for $0<k<1\cup 1<k\leq\sqrt{3/2}$ and $-\sqrt{3/2}\leq k<-1\cup -1<k<0$.

So, what I expect is the exclusion of the horizontal lines corresponding to $k=(-1,0,1)$.

  • 1
    $\begingroup$ Use the option "Exclusions" $\endgroup$ Dec 19, 2022 at 18:15

1 Answer 1


Use the Exclusions option:

  FrameLabel->{"\!\(\*FractionBox[\(\*SubscriptBox[\(m\),\(\\[Phi]\)] L\), SqrtBox[\(2\)]]\)","k"},ContourStyle->{Red,Blue},PlotLegends->{"+sign","-sign"},

enter image description here

Note that I also had to exclude k==Tanh[X].


Your Answer

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

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