DrawContinuousLegend

Prototype

void DrawContinuousLegend( Plot plot, Matrix mTickLabels, Matrix mTickPos, Matrix mTitle, Matrix mLabelSize, Matrix mColorMap, Matrix mLegendSizeFrac, Matrix mLocation )

Parameters

Plot plot
The plot to which the legend will be added.

Matrix mTickLabels
A vector of labels to accompany the color ramp. If the vector is numeric, the labels are created by applying the BEST10. format.

Matrix mTickPos
A vector of tick positions. Each element must be in [0, 1], with 0 corresponding to the bottom (or left side) of the color ramp and 1 corresponding to the top (or right side).

Matrix mTitle
A text string that appears above the color ramp. Typically this string identifies the quantity by which observations are colored.

Matrix mLabelSize
The point size (units of 1/72 inch) of the tick labels and title.

Matrix mColorMap
A k x 3 matrix or k x 1 vector of colors that defines the color ramp.

Matrix mLegendSizeFrac
A numeric vector of length 2 that specifies the size of the legend. mLegendSizeFrac[1] is a number in [0.01, 1] that specifies the width of the legend as a percentage of the plot width. mLegendSizeFrac[2] is a number in [0.01, 1] that specifies the height of the legend as a percentage of the plot height.

Matrix mLocation
A text string that specifies the position of the legend within the plot. This string has the form "PX", where P is either I (inside the Plot Area) or O (outside the Plot Area), and X is either L (left), R (right), T (top), or B (bottom). For example, common choices are "IL" (left side of the Plot Area), or "OR" (in the right graph margin). The strings "OL" and "OB" are not supported.

Remarks

This module draws a continuous legend on the plot. A continuous legend is a color ramp with a set of labels. A continuous legend indicates how observation colors relate to values of some quantity.

Example
declare DataObject dobj;
dobj = DataObject.CreateFromFile( "Iris" );
declare ScatterPlot plot;
plot = ScatterPlot.Create( dobj, "SepalLen", "SepalWid" );
plot.SetMarkerSize( 7 );

/* color code observations by values of PetalLen */
dobj.GetVarData("PetalLen", z );
SubDiv = do(10,70,1); /* determines colors and values */
numColors = ncol(SubDiv)-1;
Colors = BLUE // CYAN // YELLOW // RED ;
ColorMap = BlendColors( IntToRGB(Colors), numColors );
c = RGBToInt( ColorMap );
do i = 1 to ncol(SubDiv)-1;
    idx = loc( z >= SubDiv[i] & z < SubDiv[i+1] );
    if type(idx)^='U' then
    dobj.SetMarkerColor( idx, c[i,] );
end;

Ticks = do(10,70,10);
TickPos = (Ticks-10)/60; /* normalize to [0,1] */
LegendSizeFrac = {0.1, 0.7};
run DrawContinuousLegend( plot, Ticks, TickPos, "PetalLen",
                          8, ColorMap, LegendSizeFrac, "OR" );
See Also

BlendColors
ColorCodeObs
ColorCodeObsAndDrawLegend