2
$\begingroup$

I'm trying to make density plots of spherical harmonics. I would like the low valued regions to be transparent. For example in the following plot I want everything but the red and yellow regions to be transparent so that all four such regions are visible.

SliceDensityPlot3D[
Re@SphericalHarmonicY[3, 2, ArcTan[z, Sqrt[x^2 + y^2]], 
 ArcTan[x, y]], "CenterSphere", {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, 
 ColorFunction -> ColorData["TemperatureMap"], Boxed -> False, 
 Axes -> False, PlotPoints -> 200]

enter image description here

Another example:

SphericalPlot3D[1, {\[Theta], 0, \[Pi]}, {\[Phi], 0, 2 \[Pi]}, 
ColorFunction -> 
Function[{x, y, z, \[Theta], \[Phi], r}, 
ColorData["ThermometerColors"][
Re[SphericalHarmonicY[3, 2, \[Theta], \[Phi]]]]], 
ColorFunctionScaling -> False, Mesh -> False, Boxed -> False, 
Axes -> False, PlotPoints -> 200]

enter image description here

Is there a way to get just the white part (in another color) and add transparency to the blue part?

$\endgroup$
2
$\begingroup$

There is an example in the ColorData documentation under Applications just for this.

Create a new ColorFunction that adds an Opacity directive.

ColorFunction -> (Directive[Opacity[#], 
    ColorData["TemperatureMap"][#]] &)

enter image description here

$\endgroup$
  • $\begingroup$ Thank you. This is what I was looking for. It would be nice if the sections of negative values were totally clear and the color gradient was applied to values grater than zero with increasing intensity. $\endgroup$ – Anthony Gaussoin Oct 8 '17 at 17:16
  • $\begingroup$ I admit that this solution is much less hacky than mine =) $\endgroup$ – Henrik Schumacher Oct 8 '17 at 17:35

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.