1. Home
  2. DPIE directive

DPIE directive

Draws a pie chart on a plotter or graphics monitor.

Options

TITLE = text General title; default *
WINDOW = scalar Window number for the pie chart; default 1
KEYWINDOW = scalar Window number for the key (zero for no key); default 2
ANNOTATION = string token How to annotate each slice (description, percentage); default desc, perc
OUTLINE = string token Where to draw outlines (slices, perimeter); default slices
PENOUTLINE = scalar Pen to use for the outlines; default -10
SCREEN = string token Whether to clear the screen before plotting or to continue plotting on the old screen (clear, keep); default clea
KEYDESCRIPTION = text Overall description for the key
ENDACTION = string token Action to be taken after completing the plot (continue, pause); default * uses the setting from the last DEVICE statement

Parameters

SLICE = scalars Amounts in each of the slices (or categories)
PEN = scalars Pen number for each slice; default * uses pens 1, 2, and so on for the successive slices
DESCRIPTION = texts Description of each slice

Description

A pie chart is formed by taking the values of the scalars in the SLICE parameter, in order, and representing them by segments of a circle starting at “three o’clock” and working in an anti-clockwise direction. The angle subtended by each segment (and thus the area of the segment) is proportional to the value of the corresponding scalar. The values may be raw data or can be expressed as percentages (by ensuring they total 100).

The colour used for each segment can be controlled using the PEN parameter. By default, pen 1 is used for the first segment, pen 2 for the second segment, and so on. The default colours differ from pen to pen and can be modified using the PEN directive.

Individual segments can be displaced outwards from the centre, to obtain an “exploded” pie chart. The chosen segments are indicated by setting the corresponding scalars in the SLICE parameter list to negative values.

The WINDOW and KEYWINDOW options specify the windows in which the pie chart and key are to be displayed. The shape of the pie chart is determined by the dimensions of the window; if it is not square the resulting pie chart will be elliptical.

Titles can be added using the TITLE and KEYDESCRIPTION options. The key produced for the pie chart is similar to that produced by the DHISTOGRAM directive. A shaded block is drawn for each segment, followed by the annotation requested using the settings of the ANNOTATION option:

    description the text supplied by the DESCRIPTION parameter or, if this is not set, the identifier of the SLICE scalar;
    percentage the percentage contained in the slice.

The OUTLINE option controls whether lines are drawn around the slices or around the perimeter of the pie chart. These are drawn using the pen specified by the PENOUTLINE option (default -10). You can suppress all the outlines by setting OUTLINE=*.

The SCREEN option controls whether the graphical display is cleared before the histogram is plotted and the ENDACTION option controls whether Genstat pauses at the end of the plot.

Options: TITLE, WINDOW, KEYWINDOW, ANNOTATION, OUTLINE, PENOUTLINE, SCREEN, KEYDESCRIPTION, ENDACTION.
Parameters: SLICE, PEN, DESCRIPTION.

See also

Directives: BARCHART, DHISTOGRAM, D3HISTOGRAM, LPHISTOGRAM, FRAME, XAXIS, YAXIS, PEN.
Procedures: TRELLIS, DOTHISTOGRAM, DOTPLOT, DCIRCULAR, D2GROUPS, WINDROSE.
Commands for: Graphics.

Example

" Example DPIE-1: Draw a pie chart"

VARIATE [VALUES=1,1.1,1.2,1.3] Amount
" DPIE requires a series of numbers rather than a variate,
  so substitute the contents of the variate with the # symbol."
DPIE    [TITLE='Pie Chart'] #Amount

" Draw another, with one section exploded."
PEN     1...5; BRUSH=12,13,9,8,2
DPIE    [TITLE='Exploded Pie Chart'] 23,22,-31,10,4; PEN=1...5;\ 
        DESCRIPTION='Apples','Pears','Oranges','Bananas','Peaches'
Updated on February 7, 2023

Was this article helpful?