2
$\begingroup$
termTwo[\[Kappa]_,\[Theta]_,\[Alpha]_,A_]:=Sum[((1+A^2)Cos[m \[Theta]](Sin[(m \[Kappa])/2])^2)/m^(1+\[Alpha]), {m, 1, 200}];
ContourPlot[(termTwo[\[Kappa], \[Theta], \[Alpha], 
    A]) /. {\[Theta] -> \[Pi]/6, A -> 0.3}, {\[Kappa], 
  0, \[Pi]}, {\[Alpha], 0, 5}, 
 FrameLabel -> {Style["\[Kappa]", 16, Bold], 
   Style["\[Alpha]", 16, Bold]}, FrameStyle -> Thick, 
 PlotLegends -> Automatic]

The above code defines a function and plots it's contours per some varied parameters. I am interested only where the function is positive. How do I specify those contours?


Attempt:

ContourPlot[(termTwo[\[Kappa], \[Theta], \[Alpha], 
    A]) /. {\[Theta] -> \[Pi]/6, A -> 0.3}, {\[Kappa], 
  0, \[Pi]}, {\[Alpha], 0, 5}, 
 FrameLabel -> {Style["\[Kappa]", 16, Bold], 
   Style["\[Alpha]", 16, Bold]}, FrameStyle -> Thick, 
 PlotLegends -> Automatic, Contours -> {0}, 
 ContourShading -> {{Opacity[.5], ColorData[97][1]}, None}]

The above code does the opposite! It shows only where the function is negative.

$\endgroup$
7
  • $\begingroup$ "The above code does the opposite!" -- Did you try reversing the ContourShading? $\endgroup$
    – Michael E2
    Commented Jun 18 at 16:16
  • $\begingroup$ @MichaelE2 oops... $\endgroup$
    – KZ-Spectra
    Commented Jun 18 at 16:19
  • $\begingroup$ @MichaelE2 Should I delete the question? With the reverse shading (duh) it works as desired. $\endgroup$
    – KZ-Spectra
    Commented Jun 18 at 16:20
  • 1
    $\begingroup$ Explanation: Suppose contours are drawn a numerical levels L1, L2, etc. in increasing order. In your case, you have just one, L1 = 0. Anyway, in general, ContourShading -> {dir1, dir2,...} means the shading and level curves are done in the order dir1, L1, dir2, L2, dir3...., with the directives (dir1 etc.) cycling around if there are more levels than directives. $\endgroup$
    – Michael E2
    Commented Jun 18 at 16:20
  • $\begingroup$ I suppose you can delete the Q. Though the site seems more tolerant of things explained in the documentation than it was a few years ago. $\endgroup$
    – Michael E2
    Commented Jun 18 at 16:21

1 Answer 1

4
$\begingroup$

Answer: Try reversing the ContourShading (using Directive instead of a list sometimes prevents mis-parsing by *Plot commands):

ContourShading -> {None, Directive[Opacity[.5], ColorData[97][1]]}

Explanation: Suppose contours are drawn a numerical levels L1, L2, etc. in increasing order. In your case, you have just one, L1 = 0. Anyway, in general, ContourShading -> {dir1, dir2,...} means the shading and level curves are done in the order dir1, L1, dir2, L2, dir3...., with the directives (dir1 etc.) cycling around if there are more levels that directives.

$\endgroup$
1
  • $\begingroup$ +1 Directive[Opacity[.5], ColorData[97][1]] can be simplified to Opacity[.5, ColorData[97][1]] $\endgroup$
    – Bob Hanlon
    Commented Jun 18 at 16:42

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.