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





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. Note that not all plot commands support this option.

•

In the first calling sequence, the colorscheme option takes a list of colors and applies the "linear" or "zgradient" color scheme as described later. 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 "zgradient", or a custom procedure. The parameter schemeargs is a sequence of arguments that is passed to the procedure implementing the color scheme.

•

Note that coloring 3D surfaces based on the first two coordinates only can be done without using the colorscheme option. See the plot3d/colorfunc help page for more information.



The "linear" and "zgradient" Color Schemes


•

The "linear" color scheme is the default scheme for curves and collections of points, and the "zgradient" color scheme is the default for surfaces. In the following, the term "points" is used to encompass both curves and collections of points, since a curve is stored internally as a sequence of points.

•

The "zgradient" color scheme colors a surface or set of points according to the value of a single coordinate. With a 3D plot created by a command, such as plot3d, it colors the surface based on the $z$ value. With 2D surfaces, such as ones created by the plots:densityplot command, it colors the surface according to the function value associated with a given 2D location. With points, it colors according to the final coordinate, specifically $z$ in the 3D case and $y$ in the 2D case.

•

The "zgradient" color scheme requires a list of $n$ colors. which are distributed evenly over the surface or points. For example, if the list were ["Blue", "Green", "Red"], then the parts of the surface associated with the lowest $z$ values would be colored blue and those with the highest $z$ values would be colored red. The lower half of the $z$ values would change gradually from blue to green and those in the exact middle would be colored green.

•

The "linear" color scheme is applicable only to data that is ordered in a linear fashion, that is, to curves and collections of points. It is similar to the "zgradient" scheme but colors are distributed according to the order in which the points are stored. For example, with 100 points and a color list of ["Blue", "Green", "Red"], the first 50 points would vary from blue to green and the last 50 would vary from green to red.

•

The proportions of the $n$ colors in the list can be specified with the markers=mlist option, where mlist is a list of exactly $n$ increasing values starting with 0.0 and ending with 1.0. For example, if the color list ["Blue", "Green", "Red"] were given along with the markers=[0.0, 0.7, 1.0] option, then for the "zgradient" scheme, the lower 70% of the $z$ values would change from blue to green, and the upper 30% from green to red. Similarly, for the "linear" scheme, the first 70% of the points would change from blue to green, and the last 30% from green to red.

•

Normally, at least two colors are expected. If you provide an empty color list, then a blackandwhite coloring is used. If you provide only one color, then that color is combined with black and white. In either case, the markers option is ignored.

•

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.

•

If you want to use either the markers or colorspace option, or if you want to use the nondefault "zgradient" scheme with curves or points, then you must use the second calling sequence, where the "zgradient" or "linear" name, the color list, and the additional options are provided together in a list.



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.



Compatibility


•

The colorscheme option was introduced in Maple 18.

•

The colorscheme option was updated in Maple 2015.



Examples


Color a curve with the default "linear" scheme.
>

$\mathrm{plot}\left(\left[x\mathrm{sin}\left(x\right)\,x\mathrm{cos}\left(x\right)\,x\=0..8\mathrm{\π}\right]\,\mathrm{colorscheme}\=\left[''Orange''\,''Red''\,''NavyBlue''\right]\,\mathrm{thickness}\=3\right)$

Color a curve with the "zgradient" scheme.
>

$\mathrm{plot}\left(\left[x\mathrm{sin}\left(x\right)\,x\mathrm{cos}\left(x\right)\,x\=0..8\mathrm{\π}\right]\,\mathrm{colorscheme}\=\left[''zgradient''\,\left[''Orange''\,''Red''\,''NavyBlue''\right]\right]\,\mathrm{thickness}\=3\right)$

Use the colorscheme option in an animated curve.
>

$\mathrm{plots}:\mathrm{animatecurve}\left(\mathrm{sin}\left(x\right)\,x\=0..4\mathrm{\π}\,\mathrm{colorscheme}\=\left[''Purple''\,''Pink''\,''Blue''\right]\,\mathrm{style}\=\mathrm{point}\,\mathrm{symbol}\=\mathrm{solidcircle}\right)$

Color a density plot with the default "zgradient" scheme.
>

$\mathrm{plots}:\mathrm{densityplot}\left(\mathrm{sin}\left(xy\right)\,x\=3..3\,y\=3..3\,\'\mathrm{colorscheme}\'\=\left[''Blue''\,''Green''\,''Purple''\right]\,\'\mathrm{style}\'\=\'\mathrm{surface}\'\right)$

Change the color space to HSV.
>

$\mathrm{plots}:\mathrm{densityplot}\left(\mathrm{sin}\left(xy\right)\,x\=3..3\,y\=3..3\,\'\mathrm{colorscheme}\'\=\left[''zgradient''\,\left[''Blue''\,''Green''\,''Purple''\right]\,\'\mathrm{colorspace}\'\=''HSV''\right]\,\'\mathrm{style}\'\=\'\mathrm{surface}\'\right)$

Change the proportions of the colors by specifying markers.
>

$\mathrm{plots}:\mathrm{densityplot}\left(\mathrm{sin}\left(xy\right)\,x\=3..3\,y\=3..3\,\'\mathrm{colorscheme}\'\=\left[''zgradient''\,\left[''Blue''\,''Green''\,''Purple''\right]\,\'\mathrm{markers}\'\=\left[0.0\,0.1\,1.0\right]\right]\,\'\mathrm{style}\'\=\'\mathrm{surface}\'\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)$


