Skip to main content
deleted 174 characters in body
Source Link
Henrik Schumacher
  • 109.5k
  • 7
  • 186
  • 323

The ColorFunction of a SphericalPlot3D has fivesix arguments, the first three being the $x$, $y$ , $z$ coodinates in $\mathbb{R}^3$. The last twofourth and fifth argument are the actual parameterization parameters of the surface and the last argument is the distance from the origin (the radius).

# (Slot) and & (Function) together allow to define anonymous function. #4 and #5 refer to the fourth and fifth argument. Here is (essentially) equivalent rewrite with Function in long form:

SphericalPlot3D[1, {θ, 0, π}, {ϕ, 0, 2 π}, 
 ColorFunction -> 
  Function[
   {x, y, z, u, v}, 
   ColorData["Rainbow"][Re[SphericalHarmonicY[5, 2, u, v]]]
   ], 
 ColorFunctionScaling -> False
 ]

Compare this also toHere is the followingexample from the documentation:

gGraphicsGrid[
 =Partition[#, GraphicsRow[3] &@
  Table[SphericalPlot3D[
 Table[
  SphericalPlot3D[1 1 + Sin[5 ϕ]/10, {θ, 0, πPi}, {ϕ, 0, 2 πPi},
    PlotPoints -> 100,
    ColorFunction -> f
  ],    
  {f,
    {
     Function[{x, y, z, u, v}, ColorData["Rainbow"][(1 + Sin[5 Pi x])/2]],
     Function[{x, y, zθ, uϕ, vr}, ColorData["Rainbow"][(1 + Sin[5 Pi y])/2]]Evaluate[f]],
   
    Function[{x,PlotLabel y,-> zf, u, 
 v}, ColorData["Rainbow"][(1 + Sin[5Axes Pi-> z])/2]]None],
     Function[{xf, y{Hue[x], zHue[y], uHue[z], v}Hue[θ], ColorData["Rainbow"][(1 + Sin[5 Pi u])/2]],
     Function[{x, y, z, u, v}Hue[ϕ], ColorData["Rainbow"][(1 + Sin[5 Pi v])/2]]
     Hue[r]}
    }    
    ],   
  
 ImageSize -> Full   
  ]

enter image description hereenter image description here

The ColorFunction of a SphericalPlot3D has five arguments, the first three being the $x$, $y$ , $z$ coodinates in $\mathbb{R}^3$. The last two are the actual parameterization parameters of the surface.

# (Slot) and & (Function) together allow to define anonymous function. #4 and #5 refer to the fourth and fifth argument. Here is (essentially) equivalent rewrite with Function in long form:

SphericalPlot3D[1, {θ, 0, π}, {ϕ, 0, 2 π}, 
 ColorFunction -> 
  Function[
   {x, y, z, u, v}, 
   ColorData["Rainbow"][Re[SphericalHarmonicY[5, 2, u, v]]]
   ], 
 ColorFunctionScaling -> False
 ]

Compare this also to the following:

g = GraphicsRow[   
 Table[
  SphericalPlot3D[1, {θ, 0, π}, {ϕ, 0, 2 π},
  PlotPoints -> 100,
  ColorFunction -> f
  ],    
  {f,
    {
     Function[{x, y, z, u, v}, ColorData["Rainbow"][(1 + Sin[5 Pi x])/2]],
     Function[{x, y, z, u, v}, ColorData["Rainbow"][(1 + Sin[5 Pi y])/2]],
      Function[{x, y, z, u, v}, ColorData["Rainbow"][(1 + Sin[5 Pi z])/2]],
     Function[{x, y, z, u, v}, ColorData["Rainbow"][(1 + Sin[5 Pi u])/2]],
     Function[{x, y, z, u, v}, ColorData["Rainbow"][(1 + Sin[5 Pi v])/2]]
     }
    }    
    ],   
  ImageSize -> Full   
  ]

enter image description here

The ColorFunction of a SphericalPlot3D has six arguments, the first three being the $x$, $y$ , $z$ coodinates in $\mathbb{R}^3$. The fourth and fifth argument are the actual parameterization parameters of the surface and the last argument is the distance from the origin (the radius).

# (Slot) and & (Function) together allow to define anonymous function. #4 and #5 refer to the fourth and fifth argument. Here is (essentially) equivalent rewrite with Function in long form:

SphericalPlot3D[1, {θ, 0, π}, {ϕ, 0, 2 π}, 
 ColorFunction -> 
  Function[
   {x, y, z, u, v}, 
   ColorData["Rainbow"][Re[SphericalHarmonicY[5, 2, u, v]]]
   ], 
 ColorFunctionScaling -> False
 ]

Here is the example from the documentation:

GraphicsGrid[
 Partition[#, 3] &@
  Table[SphericalPlot3D[
    1 + Sin[5 ϕ]/10, {θ, 0, Pi}, {ϕ, 0, 2 Pi},
    PlotPoints -> 100,
    ColorFunction -> 
     Function[{x, y, z, θ, ϕ, r}, Evaluate[f]],  
    PlotLabel -> f,  
    Axes -> None], {f, {Hue[x], Hue[y], Hue[z], Hue[θ], 
     Hue[ϕ], Hue[r]}}],
  
 ImageSize -> Full
 ]

enter image description here

added 786 characters in body
Source Link
Henrik Schumacher
  • 109.5k
  • 7
  • 186
  • 323

The ColorFunction of a SphericalPlot3D has five arguments, the first three being the $x$, $y$ , $z$ coodinates in $\mathbb{R}^3$. The last two are the actual parameterization parameters of the surface.

# (Slot) and & (Function) together allow to define anonymous function. #4 and #5 refer to the fourth and fifth argument. Here is (essentially) equivalent rewrite with Function in long form:

SphericalPlot3D[1, {θ, 0, π}, {ϕ, 0, 2 π}, 
 ColorFunction -> 
  Function[
   {x, y, z, u, v}, 
   ColorData["Rainbow"][Re[SphericalHarmonicY[5, 2, u, v]]]
   ], 
 ColorFunctionScaling -> False
 ]

Compare this also to the following:

g = GraphicsRow[   
 Table[
  SphericalPlot3D[1, {θ, 0, π}, {ϕ, 0, 2 π},
  PlotPoints -> 100,
  ColorFunction -> f
  ],    
  {f,
    {
     Function[{x, y, z, u, v}, ColorData["Rainbow"][(1 + Sin[5 Pi x])/2]],
     Function[{x, y, z, u, v}, ColorData["Rainbow"][(1 + Sin[5 Pi y])/2]],
     Function[{x, y, z, u, v}, ColorData["Rainbow"][(1 + Sin[5 Pi z])/2]],
     Function[{x, y, z, u, v}, ColorData["Rainbow"][(1 + Sin[5 Pi u])/2]],
     Function[{x, y, z, u, v}, ColorData["Rainbow"][(1 + Sin[5 Pi v])/2]]
     }
    }    
    ],   
  ImageSize -> Full   
  ]

enter image description here

The ColorFunction of a SphericalPlot3D has five arguments, the first three being the $x$, $y$ , $z$ coodinates in $\mathbb{R}^3$. The last two are the actual parameterization parameters of the surface.

# (Slot) and & (Function) together allow to define anonymous function. #4 and #5 refer to the fourth and fifth argument. Here is (essentially) equivalent rewrite with Function in long form:

SphericalPlot3D[1, {θ, 0, π}, {ϕ, 0, 2 π}, 
 ColorFunction -> 
  Function[
   {x, y, z, u, v}, 
   ColorData["Rainbow"][Re[SphericalHarmonicY[5, 2, u, v]]]
   ], 
 ColorFunctionScaling -> False
 ]

The ColorFunction of a SphericalPlot3D has five arguments, the first three being the $x$, $y$ , $z$ coodinates in $\mathbb{R}^3$. The last two are the actual parameterization parameters of the surface.

# (Slot) and & (Function) together allow to define anonymous function. #4 and #5 refer to the fourth and fifth argument. Here is (essentially) equivalent rewrite with Function in long form:

SphericalPlot3D[1, {θ, 0, π}, {ϕ, 0, 2 π}, 
 ColorFunction -> 
  Function[
   {x, y, z, u, v}, 
   ColorData["Rainbow"][Re[SphericalHarmonicY[5, 2, u, v]]]
   ], 
 ColorFunctionScaling -> False
 ]

Compare this also to the following:

g = GraphicsRow[   
 Table[
  SphericalPlot3D[1, {θ, 0, π}, {ϕ, 0, 2 π},
  PlotPoints -> 100,
  ColorFunction -> f
  ],    
  {f,
    {
     Function[{x, y, z, u, v}, ColorData["Rainbow"][(1 + Sin[5 Pi x])/2]],
     Function[{x, y, z, u, v}, ColorData["Rainbow"][(1 + Sin[5 Pi y])/2]],
     Function[{x, y, z, u, v}, ColorData["Rainbow"][(1 + Sin[5 Pi z])/2]],
     Function[{x, y, z, u, v}, ColorData["Rainbow"][(1 + Sin[5 Pi u])/2]],
     Function[{x, y, z, u, v}, ColorData["Rainbow"][(1 + Sin[5 Pi v])/2]]
     }
    }    
    ],   
  ImageSize -> Full   
  ]

enter image description here

Source Link
Henrik Schumacher
  • 109.5k
  • 7
  • 186
  • 323

The ColorFunction of a SphericalPlot3D has five arguments, the first three being the $x$, $y$ , $z$ coodinates in $\mathbb{R}^3$. The last two are the actual parameterization parameters of the surface.

# (Slot) and & (Function) together allow to define anonymous function. #4 and #5 refer to the fourth and fifth argument. Here is (essentially) equivalent rewrite with Function in long form:

SphericalPlot3D[1, {θ, 0, π}, {ϕ, 0, 2 π}, 
 ColorFunction -> 
  Function[
   {x, y, z, u, v}, 
   ColorData["Rainbow"][Re[SphericalHarmonicY[5, 2, u, v]]]
   ], 
 ColorFunctionScaling -> False
 ]