Plot Coloring by Coordinate Values - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


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

Plot Coloring by Coordinate Values

 

Calling Sequence

Parameters

Summary

Introduction

Hue Coloring

RGB Coloring

Using Other Color Spaces

Options

Examples

Compatibility

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:

plot3dsinxcosy,x=0..2Pi,y=0..2Pi,colorscheme=zcoloring,z→z2

plot3dsinxcosy,x=0..2Pi,y=0..2Pi,colorscheme=zcoloring,z→z2

RGB coloring by z value:

plot3d1,u,v,u=0..2Pi,v=0..2Pi,coords=toroidal10,scaling=constrained,colorscheme=zcoloring,z→8z,z→cosz,z→0.5

Coloring by z value, using the HSV color space:

plot3dcosu,sinu,v,u=0..2Pi,v=0..10,colorscheme=zcoloring,z→cos2z,z→z2+510,z→1,colorspace=HSV,style=surface

Coloring by z value, using the CMYK color space:

plot3dcosu,sinu,v,u=0..2Pi,v=0..10,colorscheme=zcoloring,z→0.2,z→cos2z,z→z,z→0,colorspace=CMYK,style=surface

Hue coloring by x, y and z values:

plot3dsinxcosy,x=0..2Pi,y=0..2Pi,colorscheme=xyzcoloring,x,y,z→x+yz2,style=surface

RGB coloring by x, y and z values:

plot3dsinxcosy&comma;x&equals;0..2Pi&comma;y&equals;0..2Pi&comma;colorscheme&equals;xyzcoloring&comma;x&comma;y&comma;z&rarr;`if`x<1.0Pi&comma;1&comma;0&comma;x&comma;y&comma;z&rarr;`if`y<0.5Pior1.5Pi<y&comma;1&comma;0&comma;x&comma;y&comma;z&rarr;`if`z<0.5&comma;0&comma;1&comma;style&equals;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:

plot3dsinxcosy&comma;x&equals;0..2Pi&comma;y&equals;0..2Pi&comma;colorscheme&equals;xyzcoloring&comma;f&comma;style&equals;surface

Compatibility

• 

The colorscheme/coordinates option was introduced in Maple 2016.

• 

For more information on Maple 2016 changes, see Updates in Maple 2016.

See Also

ColorTools/ColorSpaces

plot/color

plot/colorscheme