1. Home
  2. DSCOLOURS procedure

DSCOLOURS procedure

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):

brbg diverging from brown to blue-grey (11)
piygdiverging from pink to yellow to green (11)
prgndiverging from purple to green (11)
puordiverging from brown to purple (11)
rdbudiverging from red to blue (11)
rdgydiverging from red to dark-grey (11)
rdybudiverging from red to yellow to blue (11)
rdygndiverging from red to yellow to green (11)
spectraldiverging from red through the spectrum to violent (11)
accentquantitative accented colours (8)
brightquantitative bright colours (12)
darkquantitative dark colours (8)
pairedquantitative paired light and dark colours (12)
pst1quantitative set 1 of pastel colours (8)
pst2quantitative set 2 of pastel colours (8)
set1quantitative set 1 of medium colours (9)
set2quantitative set 2 of medium colours (8)
set3quantitative set 3 of medium colours (12)
bluessequential from light to dark blue (9)
bugnsequential from light blue to dark green (9)
bupusequential from light blue to dark purple (9)
gnbusequential from light green to dark blue (9)
greenssequential from light to dark green (9)
greyssequential from light to dark grey (9)
orangessequential from light to dark orange (9)
orrdsequential from light orange to dark red (9)
pubusequential from light purple to dark blue (9)
pubgnsequential from light purple to blue to dark green (9)
purdsequential from light purple to dark red (9)
purplessequential from light to dark purple (9)
rdpusequential from light red to dark purple (9)
redssequential from light to dark red (9)
ylgnsequential from light yellow to dark green (9)
ylgbusequential from light yellow to green to dark blue (9)
ylobrsequential from light yellow to orange to dark brown (9)
ylordsequential from light yellow to orange to dark red (9)
 
As mentioned above, the colours in each palette can be plotted by the command
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

Procedures: DCOLOURS GETRGB 

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)

Updated on April 15, 2024

Was this article helpful?