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

Colormap 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).

Colormap Coloring

• 

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

• 

palette=P

  

A string, the name of a ColorTools:-Palette to be used as a colormap in place of a HUE coloring.

Examples

Hue coloring by z value:

plot3dsinxcosy,x=0..2π,y=0..2π,colorscheme=zcoloring,zz2

plot3dsinxcosy,x=0..2π,y=0..2π,colorscheme=zcoloring,zz2,palette=CoolWarm

RGB coloring by z value:

plot3d1,u,v,u=0..2π,v=0..2π,coords=toroidal10,scaling=constrained,colorscheme=zcoloring,z8absz,zcosz,z0.5

Coloring by z value, using the HSV color space:

plot3dcosu,sinu,v,u=0..2π,v=0..10,colorscheme=zcoloring,zcos2z,zz20+12,z1,colorspace=HSV,style=surface

Coloring by z value, using the CMYK color space:

plot3dcosu,sinu,v,u=0..2π,v=0..10,colorscheme=zcoloring,z0.2,zcos2z,zz,z0,colorspace=CMYK,style=surface

Hue coloring by x, y and z values:

plot3dsinxcosy,x=0..2π,y=0..2π,colorscheme=xyzcoloring,x,y,zx+yz2,style=surface

RGB coloring by x, y and z values:

plot3dsinxcosy&comma;x=0..2π&comma;y=0..2π&comma;colorscheme=xyzcoloring&comma;x&comma;y&comma;z`if`x<1.0π&comma;1&comma;0&comma;x&comma;y&comma;z`if`y<1.570796327or4.712388981<y&comma;1&comma;0&comma;x&comma;y&comma;z`if`absz<0.5&comma;0&comma;1&comma;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:

plot3dsinxcosy&comma;x=0..2π&comma;y=0..2π&comma;colorscheme=xyzcoloring&comma;f&comma;style=surface

Compatibility

• 

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