Visualize cloudsΒΆ

In this example we are going to draw clouds of points from a data sample.

In [1]:
from __future__ import print_function
import openturns as ot
In [2]:
# Create 2-d samples to visualize
N = 500
R = ot.CorrelationMatrix(2)
R[0,1] = -0.7
sample1 = ot.Normal([1.0]*2, [1.0]*2, R).getSample(N) # 2d N(1,1) with correlation
sample2 = ot.Normal(2).getSample(N) # 2d N(0,1) independent
In [3]:
# Create cloud drawables
cloud1 = ot.Cloud(sample1, 'blue', 'fsquare', 'First Cloud')
cloud2 = ot.Cloud(sample2, 'red', 'fsquare', 'Second Cloud')

# Then, assemble it into a graph
myGraph2d = ot.Graph('2d clouds', 'x1', 'x2', True, 'topright')
myGraph2d.add(cloud1)
myGraph2d.add(cloud2)
myGraph2d
Out[3]:
../../_images/examples_statistical_estimation_visualize_clouds_4_0.svg
In [4]:
# Create a 3-d sample
mean = [0.0] * 3
sigma = [2.0, 1.5, 1.0]
R = ot.CorrelationMatrix(3)
R[0, 1] = 0.8
R[1, 2] = -0.5
N = 500
sample3 = ot.Normal(mean, sigma, R).getSample(N)
In [5]:
# Create a Pairs drawable
pairs = ot.Pairs(sample3, 'My Pairs', ['Var1', 'Var2', 'Var3'], 'red', 'circle')

# Insert it into a graph
graph3 = ot.Graph('3d clouds')
graph3.add(pairs)
graph3
Out[5]:
../../_images/examples_statistical_estimation_visualize_clouds_6_0.svg