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.
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.
nech = 100
db = gl.Db.createFillRandom(nech, 2, 0)
db
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
gp.plot(db)
We simulate two random variables linked by a joint model
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)
err = gl.simtub(None,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
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
ax = gp.correlation(db, "Simu.1", "Simu.2", asPoint=True,
bissLine=True, flagSameAxes=True, regrLine=True)
- as cells (of a fictitious grid) painted with color representing point density
ax = gp.correlation(db, "Simu.1", "Simu.2", asPoint=False,
bissLine=True, flagSameAxes=True, regrLine=True, bins=20, cmin=1)
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.
varioparam = gl.VarioParam.createOmniDirection(npas=10, dpas=0.1)
We represent the H-Scatter plot:
- as a set of isolated symbols
ax = gp.hscatter(db, "Simu.1", "Simu.2", varioparam, ipas=8, asPoint=True,
bissLine=True, flagSameAxes=True)
- as cells (of a fictitious grid) painted with color representing point density
ax = gp.hscatter(db, "Simu.1", "Simu.2", varioparam, ipas=1, asPoint=False,
bissLine=True, flagSameAxes=True, bins=20, cmin=1)