Enhance your graphs with custom colors beyond the default Desmos palette to add a personal touch. The Graphing, Geometry, and 3D tools support various color models that accept different parameters. You can even create a list of colors to use with a list of objects or define colors in terms of coordinates in 3D. Click the following graphs to explore examples, or read on for more details.
Defining a Custom Color
Desmos calculators currently support five color functions: rgb, hsv, okhsv, oklab, and oklch. For any color function you choose, you will need to assign a variable to represent your color. If you want to use multiple custom colors in your graph, make sure to give each one a unique name.
Using the rgb Function (Red, Green, Blue)
The r, g, and b components reflect the amount of red, green, and blue light that make up a color. Each input should be a number between 0 and 255, with 0 representing no intensity of that color and 255 representing full intensity.
For example, rgb\((0, 0, 0)\) produces black, and rgb\((255, 255, 255)\) produces white.
As another example, the expression \(c=\)rgb\((86, 101, 179)\) defines a color that is a mixture of 86 units red, 101 units green, and 179 units blue.
Using the hsv and okhsv Functions (Hue, Saturation, Value)
The functions hsv and okhsv both accept three parameters that represent hue, saturation, and value. While hsv is more widely used, okhsv was designed to be a more perceptually uniform alternative.
The hue of a color is a number between 0 and 360, which represents an angle on the chromatic circle measured in degrees. View the Hue Gradient graph for examples.
The saturation of a color represents how gray a color is on a scale of 0 and 1. A saturation of 0 is the grayest, and 1 is the most vivid. View the Saturation Gradient graph for examples.
Finally, the value of a color represents how bright a color is on a scale of 0 to 1. A value of 0 is the darkest, and 1 is the brightest. View the Value Gradient graph for examples.
For example, the expression \(c=\)hsv\((230, 0.52, 0.7)\) defines a new color with a hue of 230°, 52% saturation, and a value of 70%.
Using the oklab Function (Lightness, \(a/b\) Hues)
The oklab color model is the foundation of okhsv and oklch. These models were created to match human perception of color more closely than other models. The oklab function accepts three parameters that represent perceived lightness and \(a/b\) hues.
Perceived lightness (\(L\)) represents the amount of light on a scale from 0 to 1. A perceived lightness of 0 represents deep black, and 1 is white.
The alternate \(a/b\) inputs represent opponent channels of the four unique hues (green vs red and blue vs yellow) on a scale from -0.4 to 0.4. The value of \(a\) reflects how green or red the color is. Negative values are greener, and positive values are more purple-red. The value of \(b\) controls how blue or yellow the color is. Negative values are bluer, and positive values are more yellow.
For example, \(c=\)oklab\((0.7, 0.2, -0.2)\) defines a color with a 70% lightness, a hue of more red than green, and a hue of more blue than yellow.
Using the oklch Function (Lightness, Chroma, Hue)
Similarly to oklab, the first input value of oklch defines perceived lightness on a scale from 0 to 1. A perceived lightness of 0 represents deep black, and \(L=1\) is white.
The second input is the chroma, which represents the saturation of color on a scale of 0 to 0.4. A chroma of 0 is the least colorful, and 0.4 is most colorful.
The last input is the hue, which is represented by an angle measured in degrees on a perceptually spaced color wheel with values between 0 and 360.
Using a Custom Color
You can use a custom color for any object in your graph once you define the color in the expression list and assign it a variable name.
To change the color of an object, open its Options menu by clicking and holding the color icon or entering CTRL+SHIFT+O. There, you can select any of your custom colors. Hover over any color swatch to view the name you gave it.
List of Colors
In addition to defining single colors, you can create a list of colors in two ways: referencing a list of numbers in the parameters of a color function or using a list of defined color variables.
When you assign a list of colors to a list of objects, the calculator automatically changes the colors of the objects according to order of the list. If the number of colors and objects don’t match, then the unmatched objects will not appear.
For example, if you assign a list of three colors to five circles, only the first three circles will appear.
Opacity
Opacity also influences the colors that appear in your graph. To change the opacity of an object, open the Options menu to the left of the expression by clicking and holding the color icon or entering CTRL+SHIFT+O. Then, change the value under Fill to any number from 0 to 1.
In this example, the opacity ranges from 0.2 (more transparent) to 1 (completely solid) according to the list \(T\).
Accessibility
If you plan to share your graph with others, keep in mind that individuals often experience colors differently. We recommend aiming for a contrast level of at least 3:1 in your custom colors and not relying on color alone to distinguish important elements of your graphs.
Learn More
- Coordinate-Based 3D Color Maps
- Math Art
- Lists
- Inequalities and Restrictions
- Graphing and Connecting Coordinate Points
- Global Math Art Contest
Please write in with any questions or feedback to support@desmos.com.