Plot Gradient Color Schemes - 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 Gradient Color Schemes

Plot Gradient Color Schemes

 

Calling Sequence

Parameters

Summary

Introduction

The Gradient Color Schemes

Options

Examples

Compatibility

Calling Sequence

plotcommand(plotargs, colorscheme=colorlist)

plotcommand(plotargs, colorscheme=palette)

plotcommand(plotargs, colorscheme=[scheme, opts])

Parameters

plotargs

-

arguments to a plotting command

colorlist

-

list of colors

palette

-

a ColorTools[Palette] object or a string that is a name of a KnownPalette

scheme

-

string; one of "linear", "xgradient", "ygradient", or "zgradient".

opts

-

(optional) optional arguments as described in the following Options section.

Summary

• 

Use the colorscheme option to apply a gradient color scheme to a plot.

plot3d(sin(x)*cos(y), x=0..4*Pi, y=0..4*Pi, view=[default, default, -3..3], colorscheme="Plasma");

Introduction

• 

This page describes the gradient color schemes provided by the colorscheme option, available with most plotting commands. For general information about the option and a list of other color schemes available, see the plot/colorscheme help page. A gradient color scheme can be applied to a surface, curve or set of points created by a plot command.

• 

In the first two calling sequences, the colorscheme option takes a list of  colors or a ColorTools[Palette] and applies the "linear" or "zgradient" color scheme as described in the following section. The colors may be specified in any of the forms described on the plot/color help page. If a palette is given, it is treated the same as if the list of colors returned by calling GetColors were provided.

• 

The final calling sequence must be used if one of the other schemes is requested or if additional options are to be applied.

The Gradient Color Schemes

• 

In the descriptions that follow, the word "points" is used throughout to include surfaces and curves, in addition to collections of points, referring to the data points that define these structures. Also, whenever a gradient scheme is said to require a list of colors, a ColorTools[Palette] object or the name of a known palette can be given instead.

• 

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 middle would be colored green.

• 

The "xgradient" and "ygradient" schemes are the same as the "zgradient" scheme, except that coloring is based on x and y values respectively, instead of z values. Note that the "ygradient" and "zgradient" schemes are equivalent in the 2-D case.

• 

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.

• 

When using the first calling sequence, the "linear" color scheme is the default scheme for curves and collections of points, and the "zgradient" color scheme is the default for surfaces.

Options

• 

markers=mlist

  

The proportions of the n colors in any of these schemes can be altered 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.

• 

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.

• 

zrange=r

  

This option, when used with the "zgradient" scheme, causes the colors to be mapped to the range r instead of to the range defined by the minimum and maximum values of the plot structure. This option is particularly useful in animations or arrays of plots, where is it is desirable to have colors mapping to the same values in every frame or plot. The names xrange and yrange can be given when used with the "xgradient" and "ygradient" schemes. This option is not available with the "linear" scheme.

• 

transformdata=f

  

Setting this option applies the procedure f to every data point before it is colored. For example, setting transformdata=ln with an exponential data set causes the data to be colored evenly, rather than having it skewed to the lower end of the color gradient. If used in combination with the zrange option, the zrange applies to the pre-transformed data. Using zrange in combination with a nonmonotonic transformdata function may produce unexpected results. Use caution with functions that may not be defined over the entire data set.

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 on 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.1,1.0,style=surface

Use the "xgradient" scheme to vary the color according to x-values.

Student:-Calculus1:-VolumeOfRevolutionx2+1,x=0..1,output=plot,volumeoptions=transparency=0.5,colorscheme=xgradient,Orange,Magenta

Use the zrange option to distribute the colors over a specified range. Note that the first plot does not show the entire color range from blue to orange because the z-values do not cover the entire range from -1 to 1.

optsview=0..1,0..1,1..1,colorscheme=zgradient,Blue,Purple,Orange,zrange=1..1:

p1plot3d0.5sinπxsin2πy,x=0..1,y=0..1,opts:

p2plot3dsinπxsin2πy,x=0..1,y=0..1,opts:

plots:-displayArrayp1,p2



Use the transformdata option to apply a procedure to the data before coloring. In the example where the ln function is applied to the exponential data before coloring, the data is evenly colored along the horizontal axis even though the ygradient option is being used, whereas without applying ln first, the red is dominant.

p3plotexpx,x=0..5,colorscheme=ygradient,Red,Orange,Yellow,Green,Blue,Violet,transformdata=ln,thickness=5:

p4plotexpx,x=0..5,colorscheme=ygradient,Red,Orange,Yellow,Green,Blue,Violet,thickness=5:

plots:-displayArrayp3,p4



Compatibility

• 

The colorscheme/gradient option was introduced in Maple 18.

• 

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

• 

The colorscheme/gradient option was updated in Maple 2017.

• 

The palette parameter was introduced in Maple 2022.

• 

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

See Also

ColorTools/ColorSpaces

plot/color

plot/colorscheme