G01 Chapter Contents
G01 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentG01AGF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

G01AGF performs a scatter plot of two variables on a character printing device, with a chosen number of character positions in each direction.

## 2  Specification

 SUBROUTINE G01AGF ( X, Y, NOBS, ISORT, NSTEPX, NSTEPY, IFAIL)
 INTEGER NOBS, ISORT(NOBS), NSTEPX, NSTEPY, IFAIL REAL (KIND=nag_wp) X(NOBS), Y(NOBS)

## 3  Description

G01AGF finds the range of the data in each dimension and calculates a step size for each division on the axes; these step sizes are selected from the list
 $0.1,0.15,0.2,0.25,0.4,0.5,0.6,0.75,0.8 × power of ​ 10 .$
The axes are drawn and annotated and data points are plotted on the nearest character position. The character plotted is either a digit $1$ to $9$ for the equivalent number of occurrences of a point at a particular character position, an alphabetic A–Z for $10–35$ occurrences, or * if there are more than $35$ coincident occurrences. Axes are drawn on all sides of the plot with the left-hand and bottom ones annotated; zero axes are also marked if included in the plotting area.
The Fortran logical unit number used for the output is the current advisory message unit number defined for each implementation. This number may be changed by an appropriate call to X04ABF before calling G01AGF.

None.

## 5  Parameters

1:     $\mathrm{X}\left({\mathbf{NOBS}}\right)$ – REAL (KIND=nag_wp) arrayInput
On entry: the values to be plotted in the $x$-direction.
2:     $\mathrm{Y}\left({\mathbf{NOBS}}\right)$ – REAL (KIND=nag_wp) arrayInput/Output
On entry: the values to be plotted in the $y$-direction.
On exit: the elements of Y are sorted into descending order of magnitude.
3:     $\mathrm{NOBS}$ – INTEGERInput
On entry: the number of observations to be plotted.
Constraint: ${\mathbf{NOBS}}\ge 1$.
4:     $\mathrm{ISORT}\left({\mathbf{NOBS}}\right)$ – INTEGER arrayOutput
On exit: the key to the descending order of the elements in array Y, i.e., ${\mathbf{ISORT}}\left(\mathit{i}\right)$ contains the position of the value ${\mathbf{Y}}\left(\mathit{i}\right)$ in the original array Y, for $\mathit{i}=1,2,\dots ,{\mathbf{NOBS}}$.
5:     $\mathrm{NSTEPX}$ – INTEGERInput
On entry: the number of steps (character positions) to be plotted in the $x$-direction. If the supplied value of NSTEPX is less than $10$, the value $10$ will be used by G01AGF. The maximum value for NSTEPX is the number of character positions available on the chosen output device less $15$, up to a maximum of $133$. If NSTEPX exceeds $133$ on input, the value $133$ will be used by the routine.
6:     $\mathrm{NSTEPY}$ – INTEGERInput
On entry: the number of steps (character positions) to be plotted in the $y$-direction. If the supplied value of NSTEPY is less than $10$, the value $10$ will be used by G01AGF. There is no maximum value for NSTEPY, but you should bear in mind that $\left({\mathbf{NSTEPY}}+5\right)$ records (lines) of output are generated by the routine.
7:     $\mathrm{IFAIL}$ – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
 On entry, ${\mathbf{NOBS}}<1$.
${\mathbf{IFAIL}}=-99$
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.8 in the Essential Introduction for further information.
${\mathbf{IFAIL}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
${\mathbf{IFAIL}}=-999$
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

## 7  Accuracy

Accuracy is limited by the number of plotting points available.

## 8  Parallelism and Performance

G01AGF is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

## 9  Further Comments

The time taken by G01AGF may be expected to be approximately proportional to the product ${\mathbf{NOBS}}×{\mathbf{NSTEPX}}×{\mathbf{NSTEPY}}$.
No blank records are output before or after the plot.
You must make sure that it is permissible to write records containing NSTEPX characters to the current advisory message unit.

## 10  Example

The data relate to wheat and potato yields in $48$ counties in England in 1936. The example illustrates the use of X04ABF to set the logical unit number, used for the output of G01AGF, to a specified value.

### 10.1  Program Text

Program Text (g01agfe.f90)

### 10.2  Program Data

Program Data (g01agfe.d)

### 10.3  Program Results

Program Results (g01agfe.r)