Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

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

[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:
Mark 23: output parameters have been 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 . $(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$1$ to 9$9$ for the equivalent number of occurrences of a point at a particular character position, an alphabetic A–Z for 1035$10–35$ occurrences, or * if there are more than 35$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).

None.

Parameters

Compulsory Input Parameters

1:     x(nobs) – double array
nobs, the dimension of the array, must satisfy the constraint nobs1${\mathbf{nobs}}\ge 1$.
The values to be plotted in the x$x$-direction.
2:     y(nobs) – double array
nobs, the dimension of the array, must satisfy the constraint nobs1${\mathbf{nobs}}\ge 1$.
The values to be plotted in the y$y$-direction.
3:     nstepx – int64int32nag_int scalar
The number of steps (character positions) to be plotted in the x$x$-direction. If the supplied value of nstepx is less than 10$10$, the value 10$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$15$, up to a maximum of 133$133$. If nstepx exceeds 133$133$ on input, the value 133$133$ will be used by the function.
4:     nstepy – int64int32nag_int scalar
The number of steps (character positions) to be plotted in the y$y$-direction. If the supplied value of nstepy is less than 10$10$, the value 10$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)$\left({\mathbf{nstepy}}+5\right)$ 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${\mathbf{nobs}}\ge 1$.

None.

Output Parameters

1:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).
2:     y(nobs) – double array
The elements of y are sorted into descending order of magnitude.
3:     isort(nobs) – int64int32nag_int array
The key to the descending order of the elements in array y, i.e., isort(i)${\mathbf{isort}}\left(\mathit{i}\right)$ contains the position of the value y(i)${\mathbf{y}}\left(\mathit{i}\right)$ in the original array y, for i = 1,2,,nobs$\mathit{i}=1,2,\dots ,{\mathbf{nobs}}$.

Error Indicators and Warnings

Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=1$
 On entry, nobs < 1${\mathbf{nobs}}<1$.

Accuracy

Accuracy is limited by the number of plotting points available.

The time taken by nag_stat_plot_scatter_2var (g01ag) 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.

Example

```function nag_stat_plot_scatter_2var_example
x = [16;
16;
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;
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;
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;
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);
[ifail, yOut, isort] = nag_stat_plot_scatter_2var(x, y, nstepx, nstepy)
```
```
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

ifail =

0

yOut =

8.3000
7.8000
7.2000
7.1000
6.9000
6.9000
6.7000
6.6000
6.6000
6.6000
6.5000
6.5000
6.5000
6.5000
6.4000
6.4000
6.3000
6.3000
6.3000
6.3000
6.2000
6.2000
6.1000
6.1000
6.1000
6.1000
6.0000
5.9000
5.8000
5.8000
5.8000
5.7000
5.7000
5.7000
5.6000
5.6000
5.5000
5.5000
5.4000
5.3000
5.2000
5.2000
5.2000
5.1000
5.0000
4.9000
4.9000
4.8000

isort =

10
9
45
24
5
28
20
2
15
36
21
33
42
46
7
27
8
38
39
48
12
34
3
6
14
30
13
41
37
40
43
11
31
44
26
29
4
19
47
1
22
23
35
18
32
17
25
16

```
```function g01ag_example
x = [16;
16;
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;
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;
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;
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);
[ifail, yOut, isort] = g01ag(x, y, nstepx, nstepy)
```
```
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

ifail =

0

yOut =

8.3000
7.8000
7.2000
7.1000
6.9000
6.9000
6.7000
6.6000
6.6000
6.6000
6.5000
6.5000
6.5000
6.5000
6.4000
6.4000
6.3000
6.3000
6.3000
6.3000
6.2000
6.2000
6.1000
6.1000
6.1000
6.1000
6.0000
5.9000
5.8000
5.8000
5.8000
5.7000
5.7000
5.7000
5.6000
5.6000
5.5000
5.5000
5.4000
5.3000
5.2000
5.2000
5.2000
5.1000
5.0000
4.9000
4.9000
4.8000

isort =

10
9
45
24
5
28
20
2
15
36
21
33
42
46
7
27
8
38
39
48
12
34
3
6
14
30
13
41
37
40
43
11
31
44
26
29
4
19
47
1
22
23
35
18
32
17
25
16

```