.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "tutorial/01_basic/exercises/a_load_examples_exercise.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 or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_tutorial_01_basic_exercises_a_load_examples_exercise.py: .. _load_examples: Download and Plot Examples ~~~~~~~~~~~~~~~~~~~~~~~~~~ Download and plot example datasets. PyVista contains many downloadable datasets documented at `pyvista.examples.downloads `_. You can download these through Python and immediately plot them. This is an easy way to immediately get started with example datasets within PyVista without having to manually download and load them. .. GENERATED FROM PYTHON SOURCE LINES 20-22 Import PyVista and the examples module ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 22-25 .. code-block:: Python import pyvista as pv from pyvista import examples .. GENERATED FROM PYTHON SOURCE LINES 26-30 Surface DataSet - Download ~~~~~~~~~~~~~~~~~~~~~~~~~~ Download a surface dataset of pine roots. Note how the dataset is automatically loaded right into Python. .. GENERATED FROM PYTHON SOURCE LINES 30-34 .. code-block:: Python dataset = examples.download_pine_roots() dataset .. GENERATED FROM PYTHON SOURCE LINES 35-38 Surface DataSet - Plot ~~~~~~~~~~~~~~~~~~~~~~ Plot the pine roots using PyVista's default plotting settings. .. GENERATED FROM PYTHON SOURCE LINES 38-41 .. code-block:: Python dataset.plot() .. GENERATED FROM PYTHON SOURCE LINES 42-46 Volume DataSet - Download ~~~~~~~~~~~~~~~~~~~~~~~~~ Download the bolt dataset. This is an excellent dataset to visualize using "volumetric" plotting. .. GENERATED FROM PYTHON SOURCE LINES 46-51 .. code-block:: Python dataset = examples.download_bolt_nut() dataset .. GENERATED FROM PYTHON SOURCE LINES 52-56 Volume DataSet - Plot ~~~~~~~~~~~~~~~~~~~~~ Here, we plot the dataset using a custom view direction using :class:`pyvista.Plotter`. .. GENERATED FROM PYTHON SOURCE LINES 56-68 .. code-block:: Python pl = pv.Plotter() _ = pl.add_volume( dataset, cmap="coolwarm", opacity="sigmoid_5", show_scalar_bar=False, ) pl.camera_position = [(194.6, -141.8, 182.0), (34.5, 61.0, 32.5), (-0.229, 0.45, 0.86)] pl.show() .. GENERATED FROM PYTHON SOURCE LINES 69-76 Exercise #1 - Use PyVista Examples ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Visualize one of PyVista's built in examples. If your IDE supports it, you should be able to type ``dataset = examples.download_`` and press tab to see all the available examples you can download. .. GENERATED FROM PYTHON SOURCE LINES 79-88 Exercise #2 - Download and View a File ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Experiment on your own by downloading a dataset and reading it in with :func:`pyvista.read`. You can use one of your own files or try downloading one from the following sources: - `Sample VTK DataSets `_ - `Sample STL files `_ - `Thingiverse `_ .. GENERATED FROM PYTHON SOURCE LINES 90-97 .. raw:: html
Open In Colab
.. _sphx_glr_download_tutorial_01_basic_exercises_a_load_examples_exercise.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/pyvista/pyvista-tutorial/gh-pages?urlpath=lab/tree/notebooks/tutorial/01_basic/exercises/a_load_examples_exercise.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: a_load_examples_exercise.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: a_load_examples_exercise.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_