Using Desmos: Adding Custom Colors
Created: 2025/3/10

Desmos Graphing Calculator provides several default colors for graphs and labels, and you can specify their colors.

Color Selection

Additionally, you can use custom-defined colors. Since this requires a few steps, let's go through them one by one.

Defining Colors

First, you need to define a new color and assign it to a variable. Here are some ways to define colors:

rgb (Red, Green, Blue)

rgb() specifies the proportion of red, green, and blue, each ranging from 0 to 255.

rgb

hsv (Hue, Saturation, Value)

hsv() specifies hue, saturation, and value. Hue ranges from 0 to 360, saturation from 0 to 1, and value from 0 to 1.

hsv

Using Defined Colors

Once you assign a defined color to a variable, you can use it.

Using Colors

Note that you must assign the color to a variable; otherwise, it won't appear in the options.

Advanced

Variable-Dependent Colors

The rgb() and hsv() functions can take variables as arguments. This means you can create colors that change based on variable values. You can also use curly braces {} to define conditional expressions.

1
c1=rgb(0,a,255a)c_1=\mathrm{rgb}(0,a,255-a)
2
c2={0b1:rgb(200,0,0), 1<b<2:rgb(0,200,0), 2b3:rgb(0,0,200)}c_{2}=\{\,0\le b\le 1 :\mathrm{rgb}\left(200,0,0\right),\ 1<b<2 :\mathrm{rgb}\left(0,200,0\right),\ 2\le b\le 3 :\mathrm{rgb}\left(0,0,200\right)\,\}

Defining Colors in Lists

You can use lists or for loops to define multiple colors at once.

For example, the graph below demonstrates how to plot multiple points, each with a different color:

1
P=(x,y) for x=[0,1,2] y=[0,1,2]P=(x,y)\ \mathrm{for}\ x=[\,0,1,2\,]\ y=[\,0,1,2\,]
2
c=rgb(0,200100P.x,100P.y)c=\mathrm{rgb}(0,200-100P.x,100P.y)
3
P+0.3(cost,sint)P+0.3(\cos t,\sin t)

You can even use this technique to create gradients.

1
D=[0,...,255]D=[\,0,... ,255\,]
2
c=rgb(0,255D,D)c=\mathrm{rgb}(0,255-D,D)
3
d=0.02d=0.02
4
y=dD{0x255d}y=dD\,\{0\leq x\leq 255d\}
SHARE
Images are created with the Desmos Graphing Calculator, used with permission from Desmos Studio PBC.
© 2024 UNS Physics. All Rights Reserved.