 Plot Coloring by Coordinate Values - Maple Help

Home : Support : Online Help : Graphics : 2-D : Options : colorscheme : Plot Coloring by Coordinate Values

Plot Coloring by Coordinate Values Calling Sequence plotcommand(plotargs, colorscheme=["zcoloring", zp, opts]) plotcommand(plotargs, colorscheme=["xyzcoloring", xyzp, opts]) Parameters

 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. Summary

 • 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]);  Introduction

 • 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. Hue Coloring

 • 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). RGB Coloring

 • 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. Using Other Color Spaces

 • 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. Options

 • 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. Examples

Hue coloring by $z$ value:

 > $\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["zcoloring",z→{z}^{2}\right]\right)$ > $\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["zcoloring",z→{z}^{2}\right]\right)$ RGB coloring by $z$ value:

 > $\mathrm{plot3d}\left(\left[1,u,v\right],u=0..2\mathrm{Pi},v=0..2\mathrm{Pi},\mathrm{coords}=\mathrm{toroidal}\left(10\right),\mathrm{scaling}=\mathrm{constrained},\mathrm{colorscheme}=\left["zcoloring",\left[z→8-\left|z\right|,z→\mathrm{cos}\left(z\right),z→0.5\right]\right]\right)$ Coloring by $z$ value, using the HSV color space:

 > $\mathrm{plot3d}\left(\left[\mathrm{cos}\left(u\right),\mathrm{sin}\left(u\right),v\right],u=0..2\mathrm{Pi},v=0..10,\mathrm{colorscheme}=\left["zcoloring",\left[z→\mathrm{cos}\left(2z\right),z→\frac{\frac{z}{2}+5}{10},z→1\right],\mathrm{colorspace}="HSV"\right],\mathrm{style}=\mathrm{surface}\right)$ Coloring by $z$ value, using the CMYK color space:

 > $\mathrm{plot3d}\left(\left[\mathrm{cos}\left(u\right),\mathrm{sin}\left(u\right),v\right],u=0..2\mathrm{Pi},v=0..10,\mathrm{colorscheme}=\left["zcoloring",\left[z→0.2,z→\mathrm{cos}\left(2z\right),z→z,z→0\right],\mathrm{colorspace}="CMYK"\right],\mathrm{style}=\mathrm{surface}\right)$ Hue coloring by $x$, $y$ and $z$ values:

 > $\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)$ RGB coloring by $x$, $y$ and $z$ values:

 > $\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[\left(x,y,z\right)→\mathrm{if}\left(x<1.0\mathrm{Pi},1,0\right),\left(x,y,z\right)→\mathrm{if}\left(y<0.5\mathrm{Pi}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{or}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}1.5\mathrm{Pi} Using a single procedure with 4 parameters for RGB coloring:

 > f := proc(x, y, z, A)    A := 0.0;    A := 0.0;    A := 0.0;    if x<1.0*Pi then        A := 1.0;    end if;    if y<0.5*Pi or y>1.5*Pi then        A := 1.0;    end if;    if abs(z)>=0.5 then        A := 1.0;    end if; end proc:
 > $\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",f\right],\mathrm{style}=\mathrm{surface}\right)$  Compatibility

 • The colorscheme/coordinates option was introduced in Maple 2016.