Plot Color Schemes - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Graphics : 2-D : plot/colorscheme

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 3-D 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 3-D plot created by a command, such as plot3d, it colors the surface based on the z value. With 2-D surfaces, such as ones created by the plots:-densityplot command, it colors the surface according to the function value associated with a given 2-D location. With points, it colors according to the final coordinate, specifically z in the 3-D case and y in the 2-D 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 black-and-white 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 non-default "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.

Examples

Color a curve with the default "linear" scheme.

plotxsinx,xcosx,x=0..8π,colorscheme=Orange,Red,NavyBlue,thickness=3

Color a curve with the "zgradient" scheme.

plotxsinx,xcosx,x=0..8π,colorscheme=zgradient,Orange,Red,NavyBlue,thickness=3

Use the colorscheme option in an animated curve.

plots:-animatecurvesinx,x=0..4π,colorscheme=Purple,Pink,Blue,style=point,symbol=solidcircle

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

plots:-densityplotsinxy,x=3..3,y=3..3,'colorscheme'=Blue,Green,Purple,'style'='surface'

Change the color space to HSV.

plots:-densityplotsinxy,x=3..3,y=3..3,'colorscheme'=zgradient,Blue,Green,Purple,'colorspace'=HSV,'style'='surface'

Change the proportions of the colors by specifying markers.

plots:-densityplotsinxy,x=3..3,y=3..3,'colorscheme'=zgradient,Blue,Green,Purple,'markers'=0.0,0.1,1.0,'style'='surface'

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:

plot3d2x2y2,x=5..5,y=5..5,'colorscheme'=p,0.8,0.5,'grid'=60,60,'style'='surface'

See Also

Argument Processing, ColorTools/ColorSpaces, plot/color, plot/structure, plot3d, plot3d/colorfunc, plots:-densityplot


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam