Plot Coloring by 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 Values

Plot Coloring by Values

 

Calling Sequence

Parameters

Summary

Introduction

Coloring by Value

Options

Examples

Compatibility

Calling Sequence

plotcommand(plotargs, colorscheme=["valuesplit", V, mapping, opts])

Parameters

plotargs

-

arguments to a plotting command

V

-

(optional) rtable or list of values

mapping

-

(optional) list specifying mapping of values to colors

opts

-

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

Summary

• 

Use the colorscheme option to color a plot by values.

dataplot(LinearAlgebra:-RandomVector(50), style=point, colorscheme=["valuesplit", [-infinity..-51="Blue", -50..50="DarkGreen", 51..infinity="DarkRed"]]);

Introduction

• 

This page describes how to color a plot by values using the "valuesplit" scheme with the colorscheme option, which is available for most plotting commands. Specifically, the points in a plot element are partitioned and colors are assigned to each group of points based on the associated values or the plot data itself. This color scheme can be applied to a surface, a curve, or a set of points created by a plot command.

• 

For general information about the colorscheme option and a list of other color schemes available, see the plot/colorscheme help page.

Coloring by Value

• 

In the description below, 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. A full description of the colors that can be used with plots is available on the plot/color help page.

• 

The "valuesplit" color scheme allows you to partition the points by color according to associated values. The syntax of the option is colorscheme=["valuesplit", V, mapping], where V and mapping are optional. If mapping is given, it must be in the form of a list or procedure.

• 

V is an rtable or list with n elements, where n is the number of points in the plot structure that is being colored. V can contain numerical values, names, or strings. The i-th value of V corresponds to the i-th entry of the plot data. V need not have the same dimension as the plot data. For example, if the plot is a surface constructed from an m by n grid of points, then V can be an m by n Matrix or an mn Vector with the i1n+j-th value associated with the i,j-th point.

• 

If V is not provided, then the plot data itself is used. The values are taken to be the y-coordinates of the data points for 2-D plots and the z-coordinates for 3-D plots.

• 

The most common form of mapping is a list of equalities specifying the mapping of values in V to colors. If the mapping option is not supplied, a suitable color mapping for each of the distinct elements of V is automatically created with colors chosen from the current default color palette. (See the plot/color help page for more information about default colors for plots.)

• 

For an entry s=t in the mapping list, the color t can be specified in any of the ways described on the plot/color help page. In addition to being any of the values available in V, s can also be a set or list of such values or a numerical range. For example, 3.5..5.8="Green" means that all points associated with values in V from 3.5 to 5.8 will be colored green.

• 

Optionally, the mapping list can contain a single color as the final element; this specifies the default color, which is otherwise set to black. For example, [1="Blue", 2="Red", "Yellow"] means that all points associated with value 1 will be colored blue, those associated with value 2 will be colored red, and any remaining points will be colored yellow.

• 

When a value w in V is checked against a mapping list, it is compared to each s=t entry until there is a match or the list is exhausted.  Thus, if there are two or more possible matches, the first in the list is used. The comparison is done using evalb, so values such as 4 and 4.0 are considered equivalent.

• 

The mapping argument can also be a user-provided procedure that takes a single value as input and returns a color. This would allow you to specify more complicated conditions or distinguish integer and float values.

Options

• 

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.

Examples

Color a matrix of points by a given set of values:

dataMatrixStatistics:-SampleUniform0,1,50,2|LinearAlgebra:-RandomVector50,generator=rand0..3:

plots:-pointplotdata..,1,data..,2,symbolsize=20,symbol=solidbox,colorscheme=valuesplit,data..,3,0=Red,1=Blue,2=Green,3=Purple

If no argument is supplied for the mapping argument, then colors from the default color palette are used:

plots:-pointplotdata..,1,data..,2,symbolsize=20,symbol=solidbox,colorscheme=valuesplit,data..,3

Values can be strings or names, in addition to numbers.

V1Vector4,5,7,6,3,2,2,4,6,5:

V2Vectoriris,rose,daffodil,iris,rose,daffodil,iris,iris,rose,weed:

dataplotV1,colorscheme=valuesplit,V2,iris=Indigo,rose=HotPink,daffodil=Gold,OliveDrab,style=point,symbolsize=20,view=0..10,0..10

In this example, the absolute value function is applied to the data before it is colored.

dataplotLinearAlgebra:-RandomVector50,style=point,colorscheme=valuesplit,0..30=Blue,30..60=Red,60..=Green,transformdata=abs

The "valuesplit" option can be applied to surfaces and curves, as well as points. The following command uses the z-coordinate values to determine the color of the surface.

plot3dycosx,ysinx,y,x=0..2π,y=0..1,colorscheme=valuesplit,0..0.3=NavyBlue,0.3..0.7=RoyalBlue,0.7..1.0=LightBlue

The following example shows how a custom procedure can be used with the "valuesplit" color scheme. The plot shows pitcher Dave Stieb's Earned Run Average (ERA) over the years 1979-1993. (Source: www.databasebaseball.com.) Green points indicate the years in which Stieb had more wins than losses, while the lighter colors indicate the years in which he started in fewer than 15 games.

GamesVector18,32,25,38,36,35,36,34,31,31,33,33,9,14,4:

YearVectorseqi,i=1979..1993:

WinsVector8,12,11,17,17,16,14,7,13,16,17,18,4,4,1:

LossesVector8,15,10,14,12,8,13,12,9,8,8,6,3,6,3:

ERAVector4.31,3.71,3.19,3.25,3.04,2.83,2.48,4.74,4.09,3.04,3.35,2.93,3.17,5.04,6.04,datatype=float8:

DFDataFrameGames|Wins|Losses|ERA,columns=Games,Wins,Losses,ERA,rows=Year

p := proc(i)
   if Games[i]>15 then
       return `if`(Wins[i]>Losses[i], "DarkGreen", "DarkRed");
   else
       return `if`(Wins[i]>Losses[i], "LightGreen", "RosyBrown");
   end if;
 end proc:

dataplotYear,ERA,view=1978..1994,0..7,style=point,symbolsize=20,colorscheme=valuesplit,Vector15,ii,p,labels=Year,ERA,title=ERA for Dave Stieb

Compatibility

• 

The colorscheme/valuesplit 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