Plot Color Option
Calling Sequence
Parameters
Description
Examples
Compatibility
plotcommand(plotargs, color=c)
plotcommand(plotargs, colour=c)
plotcommand
-
any plotting command such as plot or plot3d that accepts the color option
plotargs
arguments to the plot command
c
string representing a color name, an integer, a color data structure, a procedure, or an expression
The color of a plot can be specified using the option color=c, where c is an integer, string, or a color data structure. Some 3-D plotting commands can also accept a color option value in the form of a procedure or expression. For a list of color names, see the plot/colornames help page.
If an integer is given, it is used as an index into the list of default plot colors as set in plots[setcolors]. Negative indexing is supported and 0 is always interpreted as "Black".
The strings that can be given directly to a plotting command are those from the "HTML" color palette. To see a list of all colors in this palette, issue the command ColorTools:-GetPalette("HTML"). See the ColorTools:-GetPalette help page for more information.
Colors from other palettes understood by Maple can also be used by adding the palette name as a prefix in the string passed to the plotting command. For example, to generate a curve with the "Violet" color from the "Spring" palette, use the option color="Spring Violet". Use the option color="Spring n", where n is a positive integer, to get the n-th color from the "Spring" palette. Note that built-in palettes are automatically expanded as needed, so n can be larger than the number of entries shown by the ColorTools:-GetPalette command. The ColorTools:-PaletteNames command gives a list of all available palettes.
You can specify colors by their RGB values using a color data structure, which is constructed with the ColorTools:-Color command. An example is: color=ColorTools:-Color([0.5, 0.2, 0.1]). Other color spaces, such as "HSV", are also available and are described on the ColorTools/ColorSpaces help page. Multiple colors, given as Arrays of RGB, HSV or HUE values, may be provided through a color data structure as described on the plot/structure help page. You must ensure that the Array dimensions are appropriate for the plot object being displayed.
A default set of colors from the "Niagara" palette is used by certain plotting commands, including the 2-D plot command. You can change the default assignment of colors with the plots:-setcolors command.
Some 3-D plotting commands, including plot3d, also allow you to specify a procedure or an expression involving the plot variables. This feature is useful for purposes such as visualizing four-dimensional objects using color as the fourth dimension. For more information, see the plot3d/colorfunc help page. You can also apply color schemes to surfaces with the colorscheme option, as described on the plot/colorscheme help page.
plot⁡sin,color=SteelBlue
plot⁡cos,color=Niagara DarkOrchid
Color 0 is black
plot⁡cosh,color=0
Other integers are indices into the current default plot colors
plot⁡sinh,color=3
plot3d⁡sin⁡x⁢cos⁡y,x=−π..π,y=−π..π,color=−8
plot3d⁡sin⁡x⁢cos⁡y,x=−π..π,y=−π..π,color=Nautical GrayViolet
Plot the tan function in sky blue.
myskyblue≔ColorTools:-Color⁡0.196,0.6,0.8:
plot⁡tan⁡x,x=−1..1,color=myskyblue,thickness=3
Plot a randomly colored checkerboard.
p≔seq⁡seq⁡plotspolygonplot⁡i,j,i+1,j,i+1,j+1,i,j+1,color=ColorTools:-Color⁡rand⁡1012,rand⁡1012,rand⁡1012,i=1..10,j=1..10:
plotsdisplay⁡p
Create a randomly colored polygon animation sequence.
p≔seq⁡plotspolygonplot⁡0,0,1,0,1,1,0,1,axes=none,color=ColorTools:-Color⁡rand⁡1012,rand⁡1012,rand⁡1012,i=1..20:
plotsdisplay⁡p,insequence=true,axes=none
Create another polygon animation sequence using an HSV color specification.
p≔seq⁡plotspolygonplot⁡0,0,1,0,1,1,0,1,axes=none,color=ColorTools:-Color⁡HSV,0.5,0.8,i20.0,i=1..20:
The color option was updated in Maple 2022.
See Also
ColorTools
plot
plot/colornames
plot/options
plot3d
plot3d/colorfunc
plots[setcolors]
Download Help Document