PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_stat_plot_scatter_2var (g01ag)
Purpose
nag_stat_plot_scatter_2var (g01ag) performs a scatter plot of two variables on a character printing device, with a chosen number of character positions in each direction.
Syntax
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 23: |
output parameters were reordered |
Description
nag_stat_plot_scatter_2var (g01ag) 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
The axes are drawn and annotated and data points are plotted on the nearest character position. The character plotted is either a digit to for the equivalent number of occurrences of a point at a particular character position, an alphabetic A–Z for occurrences, or * if there are more than 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
nag_file_set_unit_advisory (x04ab) before calling
nag_stat_plot_scatter_2var (g01ag).
References
None.
Parameters
Compulsory Input Parameters
- 1:
– double array
-
The values to be plotted in the -direction.
- 2:
– double array
-
The values to be plotted in the -direction.
- 3:
– int64int32nag_int scalar
-
The number of steps (character positions) to be plotted in the
-direction. If the supplied value of
nstepx is less than
, the value
will be used by
nag_stat_plot_scatter_2var (g01ag). The maximum value for
nstepx is the number of character positions available on the chosen output device less
, up to a maximum of
. If
nstepx exceeds
on input, the value
will be used by the function.
- 4:
– int64int32nag_int scalar
-
The number of steps (character positions) to be plotted in the
-direction. If the supplied value of
nstepy is less than
, the value
will be used by
nag_stat_plot_scatter_2var (g01ag). There is no maximum value for
nstepy, but you should bear in mind that
records (lines) of output are generated by the function.
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the arrays
x,
y. (An error is raised if these dimensions are not equal.)
The number of observations to be plotted.
Constraint:
.
Output Parameters
- 1:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
- 2:
– double array
-
The elements of
y are sorted into descending order of magnitude.
- 3:
– int64int32nag_int array
-
The key to the descending order of the elements in array
y, i.e.,
contains the position of the value
in the original array
y, for
.
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
Accuracy is limited by the number of plotting points available.
Further Comments
The time taken by nag_stat_plot_scatter_2var (g01ag) may be expected to be approximately proportional to the product .
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.
Example
The data relate to wheat and potato yields in
counties in England in 1936. The example illustrates the use of
nag_file_set_unit_advisory (x04ab) to set the logical unit number, used for the output of
nag_stat_plot_scatter_2var (g01ag), to a specified value.
Open in the MATLAB editor:
g01ag_example
function g01ag_example
fprintf('g01ag example results\n\n');
x = [16.0 16.0 16.4 20.5 18.3 16.3 17.7 15.3;
16.5 16.9 21.9 15.5 15.9 16.1 18.5 12.7;
15.7 14.3 13.9 12.8 12.0 15.6 15.9 16.7;
14.3 14.4 15.2 14.1 15.5 16.5 14.3 13.2;
13.9 14.4 13.5 11.2 14.4 15.5 18.5 16.4;
17.1 16.9 17.5 15.9 19.2 17.7 15.2 17.1];
y = [ 5.3 6.6 6.1 5.5 6.9 6.1 6.4 6.3;
7.8 8.3 5.7 6.2 6.0 6.1 6.6 4.8;
4.9 5.1 5.5 6.7 6.5 5.2 5.2 7.1;
4.9 5.6 6.4 6.9 5.6 6.1 5.7 5.0;
6.5 6.2 5.2 6.6 5.8 6.3 6.3 5.8;
5.9 6.5 5.8 5.7 7.2 6.5 5.4 6.3];
nstepx = int64(40);
nstepy = int64(32);
fprintf(['Plot of wheat (X) and potato (Y) yields in 48 counties in', ...
'England in 1936.\n\n']);
[~, ~, ~] = g01ag( ...
x, y, nstepx, nstepy)
g01ag example results
Plot of wheat (X) and potato (Y) yields in 48 counties inEngland in 1936.
9.000+....+....+....+....+....+....+....+....+.
. .
. .
. .
. .
8.250+ 1 +
. .
. .
. 1 .
. .
7.500+ +
. .
. 1 .
. 1 .
. 1 1 .
6.750+ 1 +
. 1 1 1 .
. 1 1 1 1 2 .
. 11 1 1 .
. 1 113 .
6.000+ 1 +
. 1 1 11 .
. 1 1 1 .
. 11 1 1 .
. 1 .
5.250+ 1 12 +
. 1 .
. 1 1 1 .
. 1 .
. .
4.500+ +
. .
. .
. .
+....+....+....+....+....+....+....+....+.
10.00 14.00 18.00 22.00 26.00
12.00 16.00 20.00 24.00
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015