# Spherical harmonic plots with transparent sections

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]


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]


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

## 1 Answer

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"][#]] &)


• 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. – Anthony Gaussoin Oct 8 '17 at 17:16
• I admit that this solution is much less hacky than mine =) – Henrik Schumacher Oct 8 '17 at 17:35