hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_stat_plot_scatter_2var (g01ag)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

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

[ifail, y, isort] = g01ag(x, y, nstepx, nstepy, 'nobs', nobs)
[ifail, y, isort] = nag_stat_plot_scatter_2var(x, y, nstepx, nstepy, 'nobs', nobs)
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
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 1035 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 nag_file_set_unit_advisory (x04ab) before calling nag_stat_plot_scatter_2var (g01ag).

References

None.

Parameters

Compulsory Input Parameters

1:     xnobs – double array
The values to be plotted in the x-direction.
2:     ynobs – double array
The values to be plotted in the y-direction.
3:     nstepx int64int32nag_int scalar
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 nag_stat_plot_scatter_2var (g01ag). 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 function.
4:     nstepy int64int32nag_int scalar
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 nag_stat_plot_scatter_2var (g01ag). There is no maximum value for nstepy, but you should bear in mind that nstepy+5 records (lines) of output are generated by the function.

Optional Input Parameters

1:     nobs 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: nobs1.

Output Parameters

1:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).
2:     ynobs – double array
The elements of y are sorted into descending order of magnitude.
3:     isortnobs int64int32nag_int array
The key to the descending order of the elements in array y, i.e., isorti contains the position of the value yi in the original array y, for i=1,2,,nobs.

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=1
On entry,nobs<1.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
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 nobs×nstepx×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.

Example

The data relate to wheat and potato yields in 48 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.
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)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015