.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/scene/point_cloud.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_scene_point_cloud.py: Create a Point Cloud ==================== Demonstrates use of visual.Markers to create a point cloud with a standard turntable camera to fly around with and a centered 3D Axis. .. GENERATED FROM PYTHON SOURCE LINES 13-53 .. image-sg:: /gallery/scene/images/sphx_glr_point_cloud_001.png :alt: point cloud :srcset: /gallery/scene/images/sphx_glr_point_cloud_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy as np import vispy.scene from vispy.scene import visuals # # Make a canvas and add simple view # canvas = vispy.scene.SceneCanvas(keys='interactive', show=True) view = canvas.central_widget.add_view() # generate data pos = np.random.normal(size=(100000, 3), scale=0.2) # one could stop here for the data generation, the rest is just to make the # data look more interesting. Copied over from magnify.py centers = np.random.normal(size=(50, 3)) indexes = np.random.normal(size=100000, loc=centers.shape[0] / 2, scale=centers.shape[0] / 3) indexes = np.clip(indexes, 0, centers.shape[0] - 1).astype(int) symbols = np.random.choice(['o', '^'], len(pos)) scales = 10**(np.linspace(-2, 0.5, centers.shape[0]))[indexes][:, np.newaxis] pos *= scales pos += centers[indexes] # create scatter object and fill in the data scatter = visuals.Markers() scatter.set_data(pos, edge_width=0, face_color=(1, 1, 1, .5), size=5, symbol=symbols) view.add(scatter) view.camera = 'turntable' # or try 'arcball' # add a colored 3D axis for orientation axis = visuals.XYZAxis(parent=view.scene) if __name__ == '__main__': import sys if sys.flags.interactive != 1: vispy.app.run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.889 seconds) .. _sphx_glr_download_gallery_scene_point_cloud.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: point_cloud.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: point_cloud.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_