Wolfram: ColorFunction

By Xah Lee. Date: . Last updated: .
ColorFunction

Color the surface by a function, such as height or the parameters of the surface's function.

Used in Plot3d, ParametricPlot3D and others.

Override color specified in PlotStyle.

Value of ColorFunction is a function. the function takes 1 or more arguments, depending on the Plot function. e.g.

ColorFunction -> Function[{x, y, u, v}, GrayLevel[v]]
wl ColorFunction 2025-06-23 bFpCn
wl ColorFunction 2025-06-23 bFpCn
(* 
Color a surface by parameter v, gray levels.
also, set light to be AmbientLight, so it does not effect surface color much.
*)

ParametricPlot3D[
{Cos[u]*(2 + Cos[v]), Sin[u]*(2 + Cos[v]), Sin[v]},
{u, 0, 5}, {v, 0, 5},
SphericalRegion -> True,
 ColorFunction -> Function[{x, y, u, v}, GrayLevel[v]],
 Lighting -> AmbientLight[White]]

Example. Absolute Color of Surface, No Light.

Wolfram absolute color 2025-06-20 194bd
Wolfram absolute color 2025-06-20 194bd
Plot3D[Sin[x]  Cos[y]  (x  y), {x, 0, 3  Pi}, {y, 0, 3 Pi},
 ColorFunction ->
  Function[{x, y, z}, Directive[Glow[Hue[z]], Black, Specularity[0]]],
  Lighting -> None]

Wolfram. Plot and Visualization