Plot Color Schemes - Maple Help

Home : Support : Online Help : Graphics : 2-D : Options : colorscheme : Plot Color Schemes

Plot Color Schemes

 Calling Sequence plotcommand(plotargs, colorscheme=colorlist) plotcommand(plotargs, colorscheme=[scheme, schemeargs])

Parameters

 plotargs - arguments to a plotting command colorlist - list of colors scheme - string or procedure; name of a color scheme or a procedure that produces a color structure schemeargs - additional required arguments or keyword options for the given color scheme

Summary

 • Use the colorscheme option to apply a color scheme to a plot.
 > plot3d(1, s=0..Pi, t=0..2*Pi, coords=spherical, colorscheme=["Teal", "Purple"]);

The colorscheme Option

 • The colorscheme option allows you to apply a color scheme to a surface, curve, or set of points created by a plot command.
 • Most but not all plotting commands support this option. You can also use the colorscheme option with the plots:-display command. In this case, an attempt is made to apply the color scheme to each element of the plots passed to the command.
 • In the first calling sequence, the colorscheme option takes a list of colors and applies the "linear" or "zgradient" color scheme as described in the following section. The colors may be specified in any of the forms described on the plot/color help page.
 • In the second calling sequence, scheme is the name of a predefined color scheme, such as "xgradient", or a custom procedure. The parameter schemeargs is a sequence of arguments that is passed to the procedure implementing the color scheme. This calling sequence must be used if you wish to add a suboption such as colorspace.
 • The various color schemes available are listed here:
 – The "zcoloring" and "xyzcoloring" schemes allow you to color using functions of the $z$ value or of the $x$, $y$ and $z$ values.
 – The "valuesplit" color scheme allows you to map a collection of colors to values associated with points in the plot.
 – Procedures implementing custom color schemes can also be used.
 • Note that, when using the plot3d command, coloring 3-D surfaces based on the $x$ and $y$ coordinates can also be done without the colorscheme option. See the plot3d/colorfunc help page for more information.

 • The gradient color schemes, which include the "linear", "xgradient", "ygradient", and "zgradient" schemes, apply color gradients to plot elements. A list of colors, chosen from those described on the plot/color help page, is provided, along with optional arguments.
 • When using the first calling sequence, the "linear" color scheme is the default scheme for curves and collections of points, and the "zgradient" color scheme is the default for surfaces.
 • See plot/colorscheme/gradient for a full description of how to apply the gradient color schemes to plots.

Coloring by Coordinates

 • The "zcoloring" and "xyzcoloring" color schemes allow you to color by $z$ values or by $x$, $y$ and $z$ values.
 • See plot/colorscheme/coordinates for a full description of how to color by coordinate values.

Coloring by Values

 • The "valuesplit" color scheme allows you to partition the points by color according to associated values. For example, you can specify that all points with negative values be colored blue while all others be colored red. The values can be the plot data values themselves or they can be provided through an additional argument.
 • See plot/colorscheme/valuesplit for a full description of how to use the "valuesplit" color scheme.

Custom Color Schemes

 • You can use the second calling sequence to write a custom color scheme. This feature is recommended only for experienced Maple programmers familiar with the internal plot structure as described on the plot/structure help page.
 • The argument scheme must be a procedure that accepts as its first argument any of the plot structures (for example, MESH, GRID, POINTS) to which you will apply the color scheme. It must return a valid COLOR data structure for that plot structure. It is important to ensure that the number of colors defined by the COLOR structure matches the number of colors needed by the plot structure.
 • The remaining arguments in the sequence schemeargs are passed to procedure scheme. For example, if scheme requires a list of two colors and an integer, then these must be included in schemeargs when the colorscheme option is used. The procedure scheme can also be defined so it accepts keyword options. See the Argument Processing help page for more information.

Color Spaces

 • By default, the RGB color space is used. You can use the colorspace=t option to specify a different color space. The value t must be a string and can be any of the color spaces listed on the ColorTools/ColorSpaces help page.

Examples

Color a set of points with the default "linear" scheme.

 > $\mathrm{dataplot}\left(\left[\mathrm{seq}\left(\mathrm{sin}\left(\frac{i\mathrm{\pi }}{10}\right),i=1..20\right)\right],\mathrm{colorscheme}=\left["Orange","Blue"\right],\mathrm{style}=\mathrm{point},\mathrm{symbolsize}=20\right)$

Color a surface with the "zgradient" scheme.

 > $\mathrm{plot3d}\left(\mathrm{sin}\left(x\right)\mathrm{cos}\left(y\right),x=0..\mathrm{\pi },y=0..\mathrm{\pi },\mathrm{colorscheme}=\left["zgradient",\left["Red","Blue"\right]\right]\right)$

Color a plot using a function of $x$, $y$, and $z$ coordinates.

 > $\mathrm{plot3d}\left(\mathrm{sin}\left(x\right)\mathrm{cos}\left(y\right),x=0..2\mathrm{\pi },y=0..2\mathrm{\pi },\mathrm{colorscheme}=\left["xyzcoloring",\left(x,y,z\right)↦x+y-{z}^{2}\right],\mathrm{style}=\mathrm{surface}\right)$

Color a plot by values using the "valuesplit" scheme.

 > $\mathrm{dataplot}\left(\mathrm{LinearAlgebra}:-\mathrm{RandomMatrix}\left(20\right),\mathrm{surface},\mathrm{style}=\mathrm{point},\mathrm{colorscheme}=\left["valuesplit",\left[-\mathrm{\infty }..-1="Blue",0..\mathrm{\infty }="DarkRed"\right]\right],\mathrm{symbol}=\mathrm{solidcircle},\mathrm{symbolsize}=15\right)$

Define and use a custom color scheme.

 > p := proc(grd::specfunc(GRID), col)     local A, C, dims, r, t;     A := op(3, grd);     r := max(A)-min(A);     dims := rtable_dims(A);     C := Array(dims, 1..3, (i,j,k)->if(k=1, A[i,j]/r,         if(k=2, col[1], col[2])), 'datatype'='float[8]');     return 'COLOR'('HSV', C); end proc:
 > $\mathrm{plot3d}\left(-2{x}^{2}-{y}^{2},x=-5..5,y=-5..5,'\mathrm{colorscheme}'=\left[p,\left[0.8,0.5\right]\right],'\mathrm{grid}'=\left[60,60\right],'\mathrm{style}'='\mathrm{surface}'\right)$

Compatibility

 • The colorscheme option was introduced in Maple 18.