.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/plot_05_random_points.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_examples_plot_05_random_points.py: .. _random_surface_points_example: Random Surface Points ~~~~~~~~~~~~~~~~~~~~~~~ If only random point locations are desired, then instead of :func:`pyransame.random_surface_dataset`, :func:`pyransame.random_surface_points` can be used. Compare this example to :ref:`random_surface_sampling_example`. .. GENERATED FROM PYTHON SOURCE LINES 11-19 .. code-block:: Python import pyvista as pv from pyvista import examples import pyransame antarctica = examples.download_antarctica_velocity() .. GENERATED FROM PYTHON SOURCE LINES 20-22 The units of this mesh are in meters, which causes plotting issues over an entire continent. So the units are first converted to kilometers. .. GENERATED FROM PYTHON SOURCE LINES 22-25 .. code-block:: Python antarctica.points /= 1000.0 # convert to kilometers .. GENERATED FROM PYTHON SOURCE LINES 26-27 sample 500 points uniformly randomly. .. GENERATED FROM PYTHON SOURCE LINES 27-31 .. code-block:: Python points = pyransame.random_surface_points(antarctica, 500) points .. rst-class:: sphx-glr-script-out .. code-block:: none array([[ 347.17330964, -1778.40600422, 0. ], [ 637.92033519, -2045.06456725, 0. ], [ 777.90624057, -2048.76805509, 0. ], ..., [ 225.06692489, 2142.88450446, 0. ], [ 501.0382241 , 2062.48241245, 0. ], [ 614.05130864, 2086.59883196, 0. ]]) .. GENERATED FROM PYTHON SOURCE LINES 32-37 :func:`pyransame.random_surface_points` returns a `numpy.ndarray` object containing 500 point locations without any sampled data. To plot as spheres, we first create a `pyvista.PolyData` object. Since we did not sample any data from ``antarctica``, we do not have any scalar data, so color the spheres red. .. GENERATED FROM PYTHON SOURCE LINES 37-46 .. code-block:: Python pl = pv.Plotter() pl.add_mesh(antarctica, color="tan") spheres = pv.PolyData(points).glyph( geom=pv.Sphere(radius=50), scale=False, orient=False ) pl.add_mesh(spheres, color="red") pl.view_xy() pl.show() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/images/sphx_glr_plot_05_random_points_001.png :alt: plot 05 random points :srcset: /examples/images/sphx_glr_plot_05_random_points_001.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/pyransame/pyransame/doc/examples/images/sphx_glr_plot_05_random_points_001.vtksz .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 8.636 seconds) .. _sphx_glr_download_examples_plot_05_random_points.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_05_random_points.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_05_random_points.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_