Selects colours for graphics using colour brewer palettes (D.B. Baird).
Options
PLOT = string tokens |
What types of palette to plot (all, diverging, qualitative, sequential); default * i.e. none |
PALETTE = string token |
Palette from which to select colours (brbg, piyg, prgn, puor, rdbu, rdgy, rdybu, rdygn, spectral, accent, bright, dark, paired, pst1, pst2, set1, set2, set3, blues, bugn, bupu, gnbu, greens, greys, oranges, orrd, pubu, pubgn, purd, purples, rdpu, reds, ylgn, ylgbu, ylobr, ylord); default * i.e. no palette selected |
NCOLOURS = scalar |
Number of colours to select from the palette; default * |
CBLIND = string token |
Whether to only use palettes suitable for colour blind people (yes, no); default no |
Parameters
COLOURS = variate |
Saves the colours selected from the palette |
PENS = variate |
Pens to set with the colours selected from the palette |
Description
The DSCOLOURS procedure selects a set of colours from named Colour Brewer palettes as explained in the Method Section.The NCOLOURS option specifies the number of colours to select from the palette. This must be at least 3 and at most 8-12 depending on palette specified by the PALETTE option. The available palettes are listed below.
You can save the RGB colours in a variate, using the COLOURS parameter. Alternatively, you can set the colours of pens specified in a variate supplied by the PEN parameter. If both NCOLOURS and PENS are set, the PENS variate must be NCOLOURS in length.
A test graph can be requested by setting PLOT to diverging, qualitative, sequential, or all. The all setting displays all palettes. Otherwise, the palettes are restricted to the specified type. Diverging palettes are used to emphasise differences between the lower, middle and upper categories, qualitative palettes are used to separate a set of distinct groups, and sequential palettes show a continuous change in colours from the first group to the last. If PALETTE is set, then just the selected palette is plotted. If PLOT is set but NCOLOURS is not set, the maximum colours in each palette are displayed. Otherwise the optimum colours for the given number of colours are displayed. The CBLIND=yes option can be used to restrict the display of palettes to those suitable for colour-blind people. Also, if this is set, a fault is generated if a palette is selected that is not suitable for colour blind people.
The available palettes, and corresponding settings of the PALETTE option, are as follows (with maximum colours in brackets):
DSCOLOURS [PLOT=all]Options: PLOT, PALETTE, NCOLOURS, CBLIND.
Parameters: COLOURS, PENS.
Method
The Colour Brewer palettes from http://www.colorbrewer.org (Copyright 2002 Cynthia Brewer, Mark Harrower and The Pennsylvania State University) are used, and are obtained by the supplementary procedure _DSPALETTE. This gives optimal colours from each palette for a given number of colours.
Action with RESTRICT
Restrictions are not allowed.
See also
Directives: PEN
GenStat Reference Manual 1 Summary section on: Graphics.
Example
CAPTION ''DSCOLOURS Example'; STYLE=major
DSCOLOURS [PLOT=all] "Display all palettes"
"Example data"
FACTOR [LEVELS=8] Group; VALUES = !(20(1...8))
CALC X = !((1...20)8)
CALC [SEED=531] Y = GRUNIFORM(160)
TXCONST [TEXT=Desc] 'Group ',!(1...8); DECI=0
PEN 1...8; SYMBOL=2; CFILL='match' "Use filled symbols"
FRAME 2; XLOWER=0.68; XUPPER=1; YLOWER=0; YUPPER=0.9
"Use bright pallete with 9 columns"
DSCOLOURS [PALETTE=bright] PENS=!(1...8)
DGRAPH [T='Bright colour palette'] Y=Y; X=X; PEN=Group; DESC=Desc
DSCOLOURS [PALETTE=accent] PENS=!(1...8)
DGRAPH [T='Accent colour palette'] Y=Y; X=X; PEN=Group; DESC=Desc
"Use with sequential/diverging palettes with a contour plot"
DLOAD "Reset colours"
MATRIX [ROW=16; COLUMNS=18] M
OPEN '%Examples%/DCON-1.dat'; CHANNEL=ch; WIDTH=200
READ [PRINT=*; CHANNEL=ch] M
CLOSE ch
DSCOLOURS [PALETTE=ylgn] PENS=!(2...10)
DCONTOUR [TITLE='Contour plot with yellow-green sequential palette'] \
M; PENFILL=!(2...10)
DSCOLOURS [PALETTE=spectral] PENS=!(2...10)
DCONTOUR [TITLE='Contour plot with spectral diverging palette'] \
M; PENFILL=!(2...10)