This script is meant to demonstrate the various possibilities offered by gstlearn and gstlearn.plot for calculating and representing scatter plots or h-scatter plots.

We first define a data base containing (nech) isolated points randomly located. The samples belong to a square of mesh equal to 1.

```
nech = 100
db = Db_createFillRandom(nech, 2, 0)
```

Representing the contents of the data base

`ggplot() + plot(db) + plot.decoration(title="Data Set")`

We simulate two random variables linked by a joint model

```
model = Model(nvar=2,ndim=2)
err = model$addCovFromParam(ECov_EXPONENTIAL(),range=0.8,sills=c(2,1,1,2))
err = model$addCovFromParam(ECov_EXPONENTIAL(),range=0.2,sills=c(1.1,-1,-1,1.1))
ggplot() + plot.model(model, ivar=0, jvar=1, hmax=1)
```

```
err = simtub(NULL,db, model)
db
```

```
##
## Data Base Characteristics
## =========================
##
## Data Base Summary
## -----------------
## File is organized as a set of isolated points
## Space dimension = 2
## Number of Columns = 5
## Total number of samples = 100
##
## Variables
## ---------
## Column = 0 - Name = rank - Locator = NA
## Column = 1 - Name = x-1 - Locator = x1
## Column = 2 - Name = x-2 - Locator = x2
## Column = 3 - Name = Simu.1 - Locator = z1
## Column = 4 - Name = Simu.2 - Locator = z2
```

In this section, we present the scatter plot, represented in two different manners. On each figure, we represent the first bissector (in red) and the regression line (in blue).

- as a set of isolated points

`res = correlationPairs(db, db, "Simu.1", "Simu.2")`

```
ggplot() + plot.correlation(db, "Simu.1", "Simu.2", asPoint=TRUE,
flagBiss=TRUE, flagSameAxes=TRUE, flagRegr=TRUE)
```

- as cells (of a fictitious grid) painted with color representing point density

```
ggplot() + plot.correlation(db, "Simu.1", "Simu.2", asPoint=FALSE,
flagBiss=TRUE, flagSameAxes=TRUE, flagRegr=TRUE, bins=20)
```

In this section, we represent samples distant by a given distance. This distance is defined using the VarioParam description and selecting the lag of interest.

We first define the VarioParam set of calculation parameters: essentially, we define the lag and the number of lags.

`varioparam = VarioParam_createOmniDirection(npas=10, dpas=0.1)`

We represent the H-Scatter plot:

- as a set of isolated symbols

```
ggplot() + plot.hscatter(db, "Simu.1", "Simu.2", varioparam, ipas=8, asPoint=TRUE,
flagBiss=TRUE, flagSameAxes=TRUE)
```

- as cells (of a fictitious grid) painted with color representing point density

```
ggplot() + plot.hscatter(db, "Simu.1", "Simu.2", varioparam, ipas=1, asPoint=FALSE,
flagBiss=TRUE, flagSameAxes=TRUE, bins=20)
```