.. only:: html
.. note::
:class: sphx-glr-download-link-note
Click :ref:`here ` to download the full example code
.. rst-class:: sphx-glr-example-title
.. _sphx_glr_auto_data_analysis_graphics_plot_visualize_clouds.py:
Visualize clouds
================
In this example we are going to draw clouds of points from a data sample.
.. code-block:: default
from __future__ import print_function
import openturns as ot
import openturns.viewer as viewer
from matplotlib import pylab as plt
ot.Log.Show(ot.Log.NONE)
Create 2-d samples to visualize
.. code-block:: default
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
Create cloud drawables
.. code-block:: default
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)
view = viewer.View(myGraph2d)
.. image:: /auto_data_analysis/graphics/images/sphx_glr_plot_visualize_clouds_001.png
:alt: 2d clouds
:class: sphx-glr-single-img
Create a 3-d sample
.. code-block:: default
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
.. code-block:: default
graph3 = ot.VisualTest.DrawPairs(sample3)
graph3.setTitle('3d clouds')
view = viewer.View(graph3)
plt.show()
.. image:: /auto_data_analysis/graphics/images/sphx_glr_plot_visualize_clouds_002.png
:alt: 3d clouds
:class: sphx-glr-single-img
.. rst-class:: sphx-glr-timing
**Total running time of the script:** ( 0 minutes 0.282 seconds)
.. _sphx_glr_download_auto_data_analysis_graphics_plot_visualize_clouds.py:
.. only :: html
.. container:: sphx-glr-footer
:class: sphx-glr-footer-example
.. container:: sphx-glr-download sphx-glr-download-python
:download:`Download Python source code: plot_visualize_clouds.py `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download Jupyter notebook: plot_visualize_clouds.ipynb `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_