Plot Gradient Color Schemes - Maple Help

Home : Support : Online Help : Graphics : 2-D : Options : colorscheme : Plot Gradient Color Schemes

 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.

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

 > $\mathrm{plot}\left(\left[x\mathrm{sin}\left(x\right),x\mathrm{cos}\left(x\right),x=0..8\mathrm{Pi}\right],\mathrm{colorscheme}=\left["Orange","Red","NavyBlue"\right],\mathrm{thickness}=3\right)$

Color a curve with the "zgradient" scheme.

 > $\mathrm{plot}\left(\left[x\mathrm{sin}\left(x\right),x\mathrm{cos}\left(x\right),x=0..8\mathrm{Pi}\right],\mathrm{colorscheme}=\left["zgradient",\left["Orange","Red","NavyBlue"\right]\right],\mathrm{thickness}=3\right)$

Use the colorscheme option on an animated curve.

 > $\mathrm{plots}:-\mathrm{animatecurve}\left(\mathrm{sin}\left(x\right),x=0..4\mathrm{Pi},\mathrm{colorscheme}=\left["Purple","Pink","Blue"\right],\mathrm{style}=\mathrm{point},\mathrm{symbol}=\mathrm{solidcircle}\right)$

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

 > $\mathrm{plots}:-\mathrm{densityplot}\left(\mathrm{sin}\left(xy\right),x=-3..3,y=-3..3,'\mathrm{colorscheme}'=\left["Blue","Green","Purple"\right],'\mathrm{style}'='\mathrm{surface}'\right)$

Change the color space to HSV.

 > $\mathrm{plots}:-\mathrm{densityplot}\left(\mathrm{sin}\left(xy\right),x=-3..3,y=-3..3,'\mathrm{colorscheme}'=\left["zgradient",\left["Blue","Green","Purple"\right],'\mathrm{colorspace}'="HSV"\right],'\mathrm{style}'='\mathrm{surface}'\right)$

Change the proportions of the colors by specifying markers.

 > $\mathrm{plots}:-\mathrm{densityplot}\left(\mathrm{sin}\left(xy\right),x=-3..3,y=-3..3,'\mathrm{colorscheme}'=\left["zgradient",\left["Blue","Green","Purple"\right],'\mathrm{markers}'=\left[0.0,0.1,1.0\right]\right],'\mathrm{style}'='\mathrm{surface}'\right)$

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

 > $\mathrm{Student}:-\mathrm{Calculus1}:-\mathrm{VolumeOfRevolution}\left({x}^{2}+1,x=0..1,\mathrm{output}=\mathrm{plot},\mathrm{volumeoptions}=\left[\mathrm{transparency}=0.5,\mathrm{colorscheme}=\left["xgradient",\left["Orange","Magenta"\right]\right]\right]\right)$

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.

 > $\mathrm{opts}≔\mathrm{view}=\left[0..1,0..1,-1..1\right],\mathrm{colorscheme}=\left["zgradient",\left["Blue","Purple","Orange"\right],\mathrm{zrange}=-1..1\right]:$
 > $\mathrm{p1}≔\mathrm{plot3d}\left(0.5\mathrm{sin}\left(\mathrm{Pi}x\right)\mathrm{sin}\left(2\mathrm{Pi}y\right),x=0..1,y=0..1,\mathrm{opts}\right):$
 > $\mathrm{p2}≔\mathrm{plot3d}\left(\mathrm{sin}\left(\mathrm{Pi}x\right)\mathrm{sin}\left(2\mathrm{Pi}y\right),x=0..1,y=0..1,\mathrm{opts}\right):$
 > $\mathrm{plots}:-\mathrm{display}\left(\mathrm{Array}\left(\left[\mathrm{p1},\mathrm{p2}\right]\right)\right)$

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.

 > $\mathrm{p3}≔\mathrm{plot}\left({ⅇ}^{x},x=0..5,\mathrm{colorscheme}=\left["ygradient",\left["Red","Orange","Yellow","Green","Blue","Violet"\right],\mathrm{transformdata}=\mathrm{ln}\right],\mathrm{thickness}=5\right):$
 > $\mathrm{p4}≔\mathrm{plot}\left({ⅇ}^{x},x=0..5,\mathrm{colorscheme}=\left["ygradient",\left["Red","Orange","Yellow","Green","Blue","Violet"\right]\right],\mathrm{thickness}=5\right):$
 > $\mathrm{plots}:-\mathrm{display}\left(\mathrm{Array}\left(\left[\mathrm{p3},\mathrm{p4}\right]\right)\right)$

Compatibility

 • The colorscheme/gradient option was introduced in Maple 18.