# Understanding different parameters in the ColorFunction Command

What do these different parameters such as "#$$3$$" and "&" in ColorFunction command mean and how to use them? Thank you.

Plot3D[Exp[-x^2 - y^2], {x, -2, 2}, {y, -2, 2},
ColorFunction -> (ColorData["TemperatureMap"][#3] &)]

• The same as Plot3D[Exp[-x^2 - y^2], {x, -2, 2}, {y, -2, 2}, ColorFunction -> Function[{x, y, z}, ColorData["TemperatureMap"][z]]] Oct 6 at 5:58

& is syntactic sugar for Function. In a function definition #n refers to the nth argument. So, an expression like (#1^#2)& is literally equivalent to Function[#1^#2]. You can apply such functions to arguments in the normal way, with []. So, (#1^#2) &[a, b] and Function[#1^#2][a, b] should each give you Power[a, b].
The ColorFunction option allows you to provide your own function for how to color a plot. Plot3D is designed with its own mechanism for passing the coordinates of points to the color function (a default value for ColorFunction exists, so this process occurs for every Plot3D evaluation whether or not you provide the option explicitly). So, in the example ColorFunction -> (ColorData["TemperatureMap"][#3] &), the specified color function only cares about the 3rd coordinate. If you look at the resulting plot, you can see that color depends only on the vertical coordinate. For fun, compare the results you get by substituting ColorFunction -> (ColorData["TemperatureMap"][#2] &); it should now depend only on the "y" coordinate.
Side note: the parentheses are important. The precedence rules would interpret ColorFunction -> ColorData["TemperatureMap"][#2] & as Function[ColorFunction -> ColorData["TemperatureMap"][#2]], which is not a valid option. We want ColorFunction -> Function[ColorData["TemperatureMap"][#2]].
ColorData is a special function that produces functions. It can produce many different functions, and one of them can be specified by "TemperatureMap". Having produced a function, you can apply it to an argument: ColorData["TemperatureMap"][.75] (this example should give RGBColor[0.955963, 0.863115, 0.283425]).