1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
"""
Visualize clouds
================
"""
# %%
# In this example we are going to draw clouds of points from a data sample.
# %%
import openturns as ot
import openturns.viewer as otv
# %%
# Create 2-d samples to visualize
N = 500
R = ot.CorrelationMatrix(2)
R[0, 1] = -0.7
# 2d N(1,1) with correlation
sample1 = ot.Normal([1.0] * 2, [1.0] * 2, R).getSample(N)
sample2 = ot.Normal(2).getSample(N) # 2d N(0,1) independent
# %%
# 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, "upper right")
myGraph2d.add(cloud1)
myGraph2d.add(cloud2)
view = otv.View(myGraph2d)
# %%
# 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)
# %%
# Draw clouds pairs
graph3 = ot.VisualTest.DrawPairs(sample3)
graph3.setTitle("3d clouds")
view = otv.View(graph3)
# %%
otv.View.ShowAll()
|