NAG FL Interface
g01asf (plot_​box_​whisker)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

g01asf produces a specified number of box and whisker plots on a character printing device, with a chosen number of character positions in each direction.

2 Specification

Fortran Interface
Subroutine g01asf ( prt, m, n, x, ldx, nstepx, nstepy, plot, ldplot, fivept, iwork, ifail)
Integer, Intent (In) :: m, n(m), ldx, nstepx, nstepy, ldplot
Integer, Intent (Inout) :: ifail
Integer, Intent (Out) :: iwork(ldx)
Real (Kind=nag_wp), Intent (In) :: x(ldx,m)
Real (Kind=nag_wp), Intent (Out) :: fivept(5*m)
Character (1), Intent (In) :: prt
Character (1), Intent (InOut) :: plot(ldplot,nstepx)
C Header Interface
#include <nag.h>
void  g01asf_ (const char *prt, const Integer *m, const Integer n[], const double x[], const Integer *ldx, const Integer *nstepx, const Integer *nstepy, char plot[], const Integer *ldplot, double fivept[], Integer iwork[], Integer *ifail, const Charlen length_prt, const Charlen length_plot)
The routine may be called by the names g01asf or nagf_stat_plot_box_whisker.

3 Description

g01asf produces a series of box and whisker plots representing m data batches each of size ni, for i=1,2,,m. A box and whisker plot is a diagrammatic representation of the five-point summary of a data batch. The plot consists of a box spanning the hinges with the median indicated by a third line and two whiskers to represent the extreme values. The five-point summary is calculated internally and is returned in the workspace array.
The plot is returned in the character array plot. The size of the plot may be controlled using the arguments nstepx and nstepy. Optionally the plot can be output to an external file, in which case output is directed to the current advisory message unit as defined by x04abf.
An axis corresponding to the y axis is drawn and annotated and data points are plotted to the nearest character position.

4 References

Erickson B H and Nosanchuk T A (1985) Understanding Data Open University Press, Milton Keynes
Tukey J W (1977) Exploratory Data Analysis Addison–Wesley

5 Arguments

1: prt Character(1) Input
On entry: indicates whether the box and whisker plot is to be output to an external file.
prt='N'
The box and whisker plot is not output to an external file.
prt='P'
The box and whisker plot is output to the current advisory message unit as defined by x04abf.
Constraint: prt='P' or 'N'.
2: m Integer Input
On entry: m, the number of data batches that are to be represented.
Constraint: m>0.
3: n(m) Integer array Input
On entry: n(i) contains the number of observations in the ith batch, ni, for i=1,2,,m.
If ni<5 the ith batch is omitted from the plot.
Constraint: at least one n(i) must be greater than or equal to 5, for i=1,2,,m.
4: x(ldx,m) Real (Kind=nag_wp) array Input
On entry: the ith column of x must contain the data for the ith batch, that is x(j,i) must contain the jth observation of the ith batch, for i=1,2,,m and j=1,2,,ni.
5: ldx Integer Input
On entry: the first dimension of the array x and the dimension of the array iwork as declared in the (sub)program from which g01asf is called.
Constraint: ldxmax{n(i)}.
6: nstepx Integer Input
On entry: the number of character positions to be plotted in the x-direction.
Constraint: nstepxmax(19,(15×m/4+9)).
7: nstepy Integer Input
On entry: the number of character positions to be plotted in the y-direction.
Constraint: nstepy9.
8: plot(ldplot,nstepx) Character(1) array Output
On exit: contains the box and whisker plots.
9: ldplot Integer Input
On entry: the first dimension of the array plot as declared in the (sub)program from which g01asf is called.
Constraint: ldplotnstepy.
10: fivept(5×m) Real (Kind=nag_wp) array Output
On exit: fivept(j), for j=(i-1)×5+1,,(i-1)×5+5, contains the five-point summary of the ith batch.
11: iwork(ldx) Integer array Workspace
12: ifail Integer Input/Output
On entry: ifail must be set to 0, -1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of -1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value -1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value 0 is recommended. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6 Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
On entry, at least one element of n<5.
ifail=2
On entry, nstepx=value.
Constraint: nstepx19.
On entry, nstepx=value is too small for value plots.
ifail=3
On entry, nstepy=value.
Constraint: nstepy9.
ifail=4
On entry, ldplot=value and nstepy=value.
Constraint: ldplotnstepy.
ifail=5
On entry, prt=value.
Constraint: prt='P' or 'N'.
ifail=6
On entry, ldx=value.
Constraint: ldxvalue.
ifail=7
On entry, all batches have n<5.
ifail=8
On entry, the data values are all identical.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

If the range of observations in a particular batch is too small to allow each item of the five-point summary to be plotted separately, then a sequence of stars are plotted at the median point of the batch to indicate that the full box-plot could not be plotted.

8 Parallelism and Performance

g01asf is not threaded in any implementation.

9 Further Comments

The time taken by g01asf increases with m and ni, for i=1,2,,m.

10 Example

The following program produces a box and whisker plot for each one of 5 data batches of sizes 5, 6, 8, 8 and 7 respectively and prints the 5 box and whisker plots on the current advisory message unit.

10.1 Program Text

Program Text (g01asfe.f90)

10.2 Program Data

Program Data (g01asfe.d)

10.3 Program Results

Program Results (g01asfe.r)