Coordinate-Based 3D Color Maps

In addition to defining colors according to any of our color functions, you can also define colors in the 3D Calculator that depend directly on \((x, y, z)\) coordinates or on the parameters \(u\) and \(v\) when defining parametric surfaces. You can use coordinate-based color maps to create expressive 3D graphs, such as heatmaps, and to explore relationships between different color models.

Get started with our Custom Colors article, and then learn more with the examples and concepts on this page.

 

Defining a Color Map

Start by defining a custom color using one of the supported color functions. Then, include a reference to \((x, y, z)\) in at least one of the parameter inputs.

When you assign coordinate-based colors to a 3D graph object, the object will display a color gradient that depends on the coordinates of each point on the surface.

Screenshot of a graph of a 3D cylinder colored with an hsv gradient. 

For example, if you define a color using the function \(C=\) hsv\((250z, 1, 1)\), applying that color to a surface will create a gradient hue based on the \(z\)-values of that surface.

Screenshot of expression line showing the equation of a 3D cylinder and the color function needed to create the gradient. 

Color maps can help you visualize different color models. For example, you could explore the cylindrical relationship of the hsv color model. Hue is defined by the angle around the cylinder, saturation is defined by the radius, and value is defined by the height.

As another example, explore the RGB color space.

Screenshot of a graph of a 3D cylinder that explores the hsv color model. 

Selecting a Color Map

When you define a color map, a dynamic 3D sphere will replace the typical square color swatch. The sphere shows how the color will appear in the 3D space.

This spherical color swatch will also appear when you open an object’s Options Options icon menu to select a custom color.

You can apply color maps to 3D surfaces, including those you build implicitly, parametrically, or with functions like triangle and sphere. However, color maps don’t yet work for points or curves, such as slices of surfaces or one-variable parametric curves. For these objects, you will not see the color map swatch in the Options menu.

Screenshot of expression line showing the color map swatch in the Options menu. 

 

Parametric Color Maps

In addition to defining colors using \((x, y, z)\), you can also reference \(u\) and \(v\) to assign unique colors to parametric surfaces in 3D.

For example, you can graph the cylinder from the previous examples parametrically as \((\)cos\((u),\)sin\((u),v)\) with \(0\) \(\le\) \(u\) \(\le\) \(2\pi\) and \(0\) \(\le\) \(v\) \(\le\) \(1\). Instead of using the \(z\)-value to define a gradient that increases vertically, you can reference \(u\) in a color definition to create a gradient around the cylinder with \(C=\)hsv\((\)\(\frac{180}{π}\)\(u,1,1)\).

By defining your colors parametrically, you can add motion to your surfaces without changing the color. Explore some of these strategies in the Parametric Color Map example graph.

Screenshot of a graph of a 3D cylinder colored with a hsv gradient around the cylinder. 

 

Use 3D Points as Color Inputs

All the custom color functions in Desmos accept three numerical values as their inputs, such as (red, green, blue) for rgb, or (lightness, chroma, hue) for oklch. In addition to defining these colors explicitly using three separate numerical values, you can also use 3D points.

For example, if you have a point defined as \(A=(200,0,100)\), you can simply define a new color as \(C=\)rgb\((A)\). If you reference a list of points, you will generate a list of colors.

Screenshot of the expression list using a 3D point A=(200,0,100) and B=(200,1,[0,0.1…1]) in C1=rgb(A) and c2=hsv(B). 

 

Learn More

Please write in with any questions or feedback to support@desmos.com.