5
$\begingroup$

Can ContourPlot label contours when the plotting implicit curves? For example,

ContourPlot[Abs[Sin[x] Sin[y]] == 0.5, {x, -3, 3}, {y, -3, 3},
ContourLabels -> True]

produces

Mathematica graphics

with no visible labels, as do

ContourPlot[Abs[Sin[x] Sin[y]] == 0.5, {x, -3, 3}, {y, -3, 3}, 
ContourLabels -> "x"]

ContourPlot[Abs[Sin[x] Sin[y]] == 0.5, {x, -3, 3}, {y, -3, 3}, 
ContourLabels -> {"x"}]

and every other variant I can think of. Miraculously,

ContourPlot[Abs[Sin[x] Sin[y]] == 0.5, {x, -3, 3}, {y, -3, 3}, 
ContourLabels -> {Null, Tooltip[Null, "x"] &}]

does produce customizable Tooltips.

$\endgroup$
5
$\begingroup$

Specify Contours rather than using Equal in the first argument

ContourPlot[Abs[Sin[x] Sin[y]], {x, -3, 3}, {y, -3, 3}, 
    ContourLabels -> (Text[Framed[#3], {#1, #2}, Background -> White] &),
                Contours -> {0.5}, ContourStyle -> Blue, ContourShading -> None]

$\endgroup$
  • $\begingroup$ Thanks, I seem to recall this approach from older versions. The contours appear a bit thinner, but it's acceptable. I had tried it myself with ContourShading -> False and those contours were unacceptably thin! $\endgroup$ – Chris K Jan 11 '18 at 22:39
  • 1
    $\begingroup$ @ChrisK Replacing the style by ContourStyle -> Directive[Thickness[0.01], Blue] makes them thick $\endgroup$ – Coolwater Jan 11 '18 at 22:58

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.