1. Home
  2. D2GROUPS procedure

D2GROUPS procedure

Displays the distribution of groups in a plane using a trellis of bar or pie charts (R.W. Payne).


COLOURS = variate or text

PLOT = string tokens What to plot (barchart, piechart, scaledpiechart, key); default barc, key
NPARTITIONS = scalar Number of partitions along each axis; default 8
COLOURS = variate or text Colours for the groups; default uses the colours defined for pens 2 upwards
EQUALAXES = string tokens What aspect of the x- and y-axes to make equal (bounds, scaling); default * i.e. none
KEYHEIGHT = scalar Height of the key; default 0.1
LABELSIZE = scalar Size of labels showing the number of points in each unscaled pie chart; default 1
%MARGINSIZE = scalar Ratio as a percentage for margin sizes to their default sizes in pie charts; default 100


Y = variates Y-coordinates of the points in each graph 
X = variates X-coordinates of the points in each graph
GROUPS = factors Groupings for the points in each graph
TITLE = texts Title for each graph


D2GROUPS is useful when you have large numbers of points that are classified into groups. The x- and y-coordinates of the points are supplied by the X and Y parameters, and their groups are specified by the GROUPS parameter. D2GROUPS divides the plane into a trellis of squares, and calculates the replications of the groups within each of the squares. The PLOT option specifies how the replications are plotted, with settings:

barchart plots a trellis with a bar chart in each square,

piechart plots a trellis with a pie chart in each square, with a label on the left at the top showing the number of points in the square,

scaledpiechart plots a trellis with a pie chart in each square, each one scaled according to the number of points in the square, and

key includes a key showing the colour used for each group. The default is to plot a bar chart with a key.

The NPARTITIONS option specifies the number of partitions (i.e. the number of tellis boxes) along each axis; default 8. The COLOURS option can specify either a variate or a text to define the colours to be used for the groups. (See PEN for details.) The default is to use the colours defined for pens 2 upwards. The EQUALAXES option allows you to specify that the x- and y-axes should share equal bounds or have equal scaling. By default, they will have their own bounds and scaling, The KEYHEIGHT option specifies the height of the key. This must not be less than 0.1 or greater than 0.5. The default is 0.1. The LABELSIZE option specifies the size of the labels showing the number of points in each unscaled pie chart; default 1. The %MARGINSIZE option specifies the ratio (as a percentage) of the margin sizes in pie charts to their default sizes; default 100. The TITLE parameter can supply a title for the plots; by default there is none. Options: PLOT, NPARTITIONS, COLOURS, KEYHEIGHT, LABELSIZE, %MARGINSIZE. Parameters: Y, X, GROUPS, TITLE.

Action with RESTRICT

If either X, Y or GROUPS is restricted, only the units not excluded by the restriction will be plotted.

See also

Commands for: Graphics.


CAPTION  'D2GROUPS example'; STYLE=meta
SPLOAD   '%data%/Iris.gsh' 
D2GROUPS Y=Petal_Length; X=Petal_Width; GROUPS=Species
&        [PLOT=barchart,piechart,key] Y=Sepal_Length; X=Sepal_Width; GROUPS=Species
Updated on February 6, 2023

Was this article helpful?