1
$\begingroup$

From this interesting link How to simultaneously extract contourvalues and contourline? I've learnd how to extract the contourvalues from a ContourPlot-graphicsobject.

Is it possible to extend this approach to ContourPlot3D?

For example

plt = ContourPlot3D[Sqrt[4/(Pi)^2] Sin[1 x] Sin[2 y] Sin[2 z] , {x, 0, Pi}, {y, 0,Pi}, {z, 0, Pi}, Mesh -> None, Axes -> False, Boxed -> False]

enter image description here

shows some different contours whose value I would like to know.

I tried

poly = Cases[plt, GraphicsGroup[p_] -> p, Infinity]

which gives three groups of polygons (probably the contours I'm looking for), but doesn't show a contourvalue!

No idea how to proceed!

Thanks!

$\endgroup$

1 Answer 1

2
$\begingroup$

Add

PlotLegends -> Automatic
plt = ContourPlot3D[
  Sqrt[4/(Pi)^2] Sin[1 x] Sin[2 y] Sin[2 z], {x, 0, Pi}, {y, 0, 
   Pi}, {z, 0, Pi}, Mesh -> None, Axes -> False, Boxed -> False, 
  PlotLegends -> Automatic]
Cases[plt, SwatchLegend[a__] :> a, Infinity][[2]]

enter image description here

$\endgroup$
2
  • $\begingroup$ Thanks, very good idea. But Cases misses the contourvalue 0! $\endgroup$ Commented Nov 18, 2021 at 10:13
  • $\begingroup$ That's it, thank you very much. Didn't know SwatchLegend $\endgroup$ Commented Nov 18, 2021 at 10:29

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.