This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
How to | Use Colors in Mathematica
As well as being able to specify colors in several color spaces, Mathematica also contains a variety of predefined colors and aesthetically pleasing color spectrums. These colors can be applied to just about anything.
This is a selection of examples from the complete "How to" screencast. »
The quickest way to access all the colors in Mathematica is through the Color Schemes palette, which can be found in the Palettes menu:
The palette lists the colors in collections such as Gradients, Physical, Named, and Indexed. Each collection contains a spectrum of colors. The value or range of values corresponding to the selected color is given above the Insert button for the collection.
Here, Red was inserted from the Named collection. Evaluating a named color returns the RGB value of that color:
Click for copyable input
You can convert to other color spaces by using :
Click for copyable input
The Gradients collection on the palette provides a spectrum of colors with a range of indices. Here, the Dark Rainbow color gradient was inserted using the palette.
Evaluating this reveals the underlying ColorData function structure, with the acceptable range of indices listed. In this case, the indices can range from to :
Click for copyable input
To retrieve the specific color value, the index can be specified as the second argument to ColorData:
Click for copyable input
This can be used directly in a graphics expression
Click for copyable input
You can also create a variable index by using Manipulate:
Here is an example of a 3D plot from the ColorData documentation page. Notice how the values closer to 0 appear in cool colors (blue), while the values closer to 1 appear in warm colors (red):
Click for copyable input