2
$\begingroup$

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)$.

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

1 Answer 1

6
$\begingroup$

Use the Exclusions option:

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"},
  Exclusions->{k==0,k==1,k==-1,k==Tanh[X]}]

enter image description here

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

$\endgroup$

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.