Scatter and H-scatter plotsΒΆ

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.

In [1]:
import gstlearn as gl
import gstlearn.plot as gp

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

In [2]:
nech = 100
db = gl.Db.createFillRandom(nech, 2, 0)
db
Out[2]:
Data Base Characteristics
=========================

Data Base Summary
-----------------
File is organized as a set of isolated points
Space dimension              = 2
Number of Columns            = 3
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

Representing the contents of the data base

In [3]:
gp.plot(db)
No description has been provided for this image

We simulate two random variables linked by a joint model

In [4]:
model = gl.Model(2,2)
model.addCovFromParam(gl.ECov.EXPONENTIAL,range=0.8,sills=[2,1,1,2])
model.addCovFromParam(gl.ECov.EXPONENTIAL,range=0.2,sills=[1.1,-1,-1,1.1])
ax = gp.model(model, ivar=0, jvar=1, hmax=1)
No description has been provided for this image
In [5]:
err = gl.simtub(None,db, model)
db
Out[5]:
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

Scatter plotΒΆ

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
In [6]:
ax = gp.correlation(db, "Simu.1", "Simu.2", asPoint=True, 
                    bissLine=True, flagSameAxes=True, regrLine=True)
No description has been provided for this image
  • as cells (of a fictitious grid) painted with color representing point density
In [7]:
ax = gp.correlation(db, "Simu.1", "Simu.2", asPoint=False, 
                    bissLine=True, flagSameAxes=True, regrLine=True, bins=20, cmin=1)
No description has been provided for this image

H-Scatter plotΒΆ

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.

In [8]:
varioparam = gl.VarioParam.createOmniDirection(npas=10, dpas=0.1)

We represent the H-Scatter plot:

  • as a set of isolated symbols
In [9]:
ax = gp.hscatter(db, "Simu.1", "Simu.2", varioparam, ipas=8, asPoint=True, 
                 bissLine=True, flagSameAxes=True)
No description has been provided for this image
  • as cells (of a fictitious grid) painted with color representing point density
In [10]:
ax = gp.hscatter(db, "Simu.1", "Simu.2", varioparam, ipas=1, asPoint=False, 
                    bissLine=True, flagSameAxes=True, bins=20, cmin=1)
No description has been provided for this image