Plot Coloring by Coordinate Values
Calling Sequence
Parameters
Summary
Introduction
Hue Coloring
Colormap Coloring
RGB Coloring
Using Other Color Spaces
Options
Examples
Compatibility
plotcommand(plotargs, colorscheme=["zcoloring", zp, opts])
plotcommand(plotargs, colorscheme=["xyzcoloring", xyzp, opts])
plotargs
-
arguments to a plotting command
zp
procedure or list of procedures, all having one input parameter
xyzp
procedure or list of procedures, all having three input parameters, or procedure with four input parameters
opts
(optional) optional arguments as described in the following Options section.
Use the colorscheme option to color a plot with functions of the coordinate values
plot3d(sin(x)*cos(y), x=0..2*Pi, y=0..2*Pi, colorscheme=["zcoloring", z->z^2]);
This page describes how to color a plot element using functions of its x, y and z coordinate values. This is done with the "zcoloring" and "xyzcoloring" schemes of the colorscheme option, which is available for most plotting commands.
The function values, computed through procedures, can represent RGB or hue values, or values from any other color space described on the ColorTools/ColorSpaces help page.
For general information about the colorscheme option and a list of other color schemes available, see the plot/colorscheme help page.
Plots can be colored with hue values ranging from 0 to 1. If the values given through the zp or xyzp procedures fall outside this range, they will be normalized so that the minimum value is 0 and the maximum is 1.
The first calling sequence, which invokes the "zcoloring" scheme, is used when the color is a function of z only. In this case, zp must be a procedure having one input parameter (the z coordinate value) and returning a single numeric value (the hue value).
The second calling sequence, which invokes the "xyzcoloring" scheme, is used when the color is a function of x, y and z values. In this case, xyzp must be a procedure having three input parameters (the x, y and z coordinate values) and returning a single numeric value (the hue value).
Use the Plots can be colored using a palette as a colormap with values ranging from 0 to 1. This uses the same calling sequences as Hue Coloring described above with the addition of the palette=P option where P is a palette name or object which is passed to ColorTools:-Blend to compute the colors of the colormap.
RGB values can be computed with three separate procedures.
The first calling sequence, which invokes the "zcoloring" scheme, is used when the color is a function of z only. In this case, zp must be a list of 3 procedures, each having one input parameter (the z coordinate value) and returning a single numeric value (the R, G or B component).
The second calling sequence, which invokes the "xyzcoloring" scheme, is used when the color is a function of x, y and z values. In this case, xyzp must be a list of three procedures, each having three input parameters (the x, y and z coordinate values) and returning a single numeric value (the R, G or B component).
The second calling sequence also allows you to provide a single procedure with four input parameters. The first three hold the x, y and z values. The fourth is a 3-element Vector or Array A. The procedure computes the R, G and B values for given values of x, y and z and returns these values through A.
Instead of RGB coloring, you can provide color values in any of the color spaces described on the ColorTools/ColorSpaces help page, using the colorspace option.
The second calling sequence is used in the same way as described for RGB coloring, for any of the 3-component color spaces. For a color space with N components, such as CMYK, which has 4 components, the list of 3 procedures should be replaced by a list of N procedures.
If a single 4-argument procedure is being used, then the Vector or Array A must contain N elements, to match the number of components required for the alternate color space.
colorspace=t
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.
palette=P
A string, the name of a ColorTools:-Palette to be used as a colormap in place of a HUE coloring.
Hue coloring by z value:
plot3d⁡sin⁡x⁢cos⁡y,x=0..2⁢π,y=0..2⁢π,colorscheme=zcoloring,z↦z2
plot3d⁡sin⁡x⁢cos⁡y,x=0..2⁢π,y=0..2⁢π,colorscheme=zcoloring,z↦z2,palette=CoolWarm
RGB coloring by z value:
plot3d⁡1,u,v,u=0..2⁢π,v=0..2⁢π,coords=toroidal⁡10,scaling=constrained,colorscheme=zcoloring,z↦8−abs⁡z,z↦cos⁡z,z↦0.5
Coloring by z value, using the HSV color space:
plot3d⁡cos⁡u,sin⁡u,v,u=0..2⁢π,v=0..10,colorscheme=zcoloring,z↦cos⁡2⋅z,z↦z20+12,z↦1,colorspace=HSV,style=surface
Coloring by z value, using the CMYK color space:
plot3d⁡cos⁡u,sin⁡u,v,u=0..2⁢π,v=0..10,colorscheme=zcoloring,z↦0.2,z↦cos⁡2⋅z,z↦z,z↦0,colorspace=CMYK,style=surface
Hue coloring by x, y and z values:
plot3d⁡sin⁡x⁢cos⁡y,x=0..2⁢π,y=0..2⁢π,colorscheme=xyzcoloring,x,y,z↦x+y−z2,style=surface
RGB coloring by x, y and z values:
plot3d⁡sin⁡x⁢cos⁡y,x=0..2⁢π,y=0..2⁢π,colorscheme=xyzcoloring,x,y,z↦`if`⁡x<1.0⋅π,1,0,x,y,z↦`if`⁡y<1.570796327or4.712388981<y,1,0,x,y,z↦`if`⁡abs⁡z<0.5,0,1,style=surface
Using a single procedure with 4 parameters for RGB coloring:
f := proc(x, y, z, A) A[1] := 0.0; A[2] := 0.0; A[3] := 0.0; if x<1.0*Pi then A[1] := 1.0; end if; if y<0.5*Pi or y>1.5*Pi then A[2] := 1.0; end if; if abs(z)>=0.5 then A[3] := 1.0; end if; end proc:
plot3d⁡sin⁡x⁢cos⁡y,x=0..2⁢π,y=0..2⁢π,colorscheme=xyzcoloring,f,style=surface
The colorscheme/coordinates option was introduced in Maple 2016.
For more information on Maple 2016 changes, see Updates in Maple 2016.
The palette option was introduced in Maple 2024.
For more information on Maple 2024 changes, see Updates in Maple 2024.
See Also
ColorTools/ColorSpaces
plot/color
plot/colorscheme
Download Help Document