
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "tutorial/01_basic/solutions/a_load_examples_solution.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_tutorial_01_basic_solutions_a_load_examples_solution.py>`
        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_solutions_a_load_examples_solution.py:


.. _load_examples_solution:

Download and Plot Examples
~~~~~~~~~~~~~~~~~~~~~~~~~~

.. note::
   This is the solution to :ref:`load_examples`. If you haven't already tried to
   solve it on your own, you probably should try that first.

Download and plot example datasets.

PyVista contains many downloadable datasets documented at
`pyvista.examples.downloads
<https://docs.pyvista.org/api/examples/_autosummary/pyvista.examples.downloads.html>`_. You can download these through Python and then 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 23-25

Import PyVista and the examples module
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. GENERATED FROM PYTHON SOURCE LINES 25-28

.. code-block:: Python

    import pyvista as pv
    from pyvista import examples








.. GENERATED FROM PYTHON SOURCE LINES 29-33

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 33-37

.. code-block:: Python

    dataset = examples.download_pine_roots()
    dataset







.. raw:: html

    <div class="output_subarea output_html rendered_html output_result">
    <table style='width: 100%;'><tr><th>Header</th><th>Data Arrays</th></tr><tr><td>
    <table style='width: 100%;'>
    <tr><th>PolyData</th><th>Information</th></tr>
    <tr><td>N Cells</td><td>351536</td></tr>
    <tr><td>N Points</td><td>178091</td></tr>
    <tr><td>N Strips</td><td>0</td></tr>
    <tr><td>X Bounds</td><td>2.742e+00, 7.847e+01</td></tr>
    <tr><td>Y Bounds</td><td>0.000e+00, 7.969e+01</td></tr>
    <tr><td>Z Bounds</td><td>0.000e+00, 9.961e+01</td></tr>
    <tr><td>N Arrays</td><td>1</td></tr>
    </table>

    </td><td>
    <table style='width: 100%;'>
    <tr><th>Name</th><th>Field</th><th>Type</th><th>N Comp</th><th>Min</th><th>Max</th></tr>
    <tr><td>Unnamed_0</td><td>Points</td><td>float32</td><td>3</td><td>-1.000e+00</td><td>1.000e+00</td></tr>
    </table>

    </td></tr> </table>
    </div>
    <br />
    <br />

.. GENERATED FROM PYTHON SOURCE LINES 38-41

Surface DataSet - Plot
~~~~~~~~~~~~~~~~~~~~~~
Plot the pine roots using PyVista's default plotting settings.

.. GENERATED FROM PYTHON SOURCE LINES 41-44

.. code-block:: Python

    dataset.plot()









.. tab-set::



   .. tab-item:: Static Scene



            
     .. image-sg:: /tutorial/01_basic/solutions/images/sphx_glr_a_load_examples_solution_001.png
        :alt: a load examples solution
        :srcset: /tutorial/01_basic/solutions/images/sphx_glr_a_load_examples_solution_001.png
        :class: sphx-glr-single-img
     


   .. tab-item:: Interactive Scene



       .. offlineviewer:: /home/runner/work/pyvista-tutorial/pyvista-tutorial/doc/source/tutorial/01_basic/solutions/images/sphx_glr_a_load_examples_solution_001.vtksz






.. GENERATED FROM PYTHON SOURCE LINES 45-49

Volume DataSet - Download
~~~~~~~~~~~~~~~~~~~~~~~~~
Download the bolt dataset. This is an excellent dataset to visualize using
"volumetric" plotting.

.. GENERATED FROM PYTHON SOURCE LINES 49-54

.. code-block:: Python


    dataset = examples.download_bolt_nut()
    dataset







.. raw:: html

    <div class="output_subarea output_html rendered_html output_result">
    <table style='width: 100%;'><tr><th>Information</th><th>Blocks</th></tr><tr><td>
    <table>
    <tr><th>MultiBlock</th><th>Values</th></tr>
    <tr><td>N Blocks:</td><td>2</td></tr>
    <tr><td>X Bounds:</td><td>0.000e+00, 6.900e+01</td></tr>
    <tr><td>Y Bounds:</td><td>0.000e+00, 1.220e+02</td></tr>
    <tr><td>Z Bounds:</td><td>0.000e+00, 6.500e+01</td></tr>
    </table>

    </td><td>
    <table>
    <tr><th>Index</th><th>Name</th><th>Type</th></tr>
    <tr><th>0</th><th>bolt</th><th>ImageData</th></tr>
    <tr><th>1</th><th>nut</th><th>ImageData</th></tr>
    </table>

    </td></tr> </table>
    </div>
    <br />
    <br />

.. GENERATED FROM PYTHON SOURCE LINES 55-59

Volume DataSet - Plot
~~~~~~~~~~~~~~~~~~~~~
Here, we plot the dataset using a custom view direction using
:class:`pyvista.Plotter`.

.. GENERATED FROM PYTHON SOURCE LINES 59-71

.. 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()









.. tab-set::



   .. tab-item:: Static Scene



            
     .. image-sg:: /tutorial/01_basic/solutions/images/sphx_glr_a_load_examples_solution_002.png
        :alt: a load examples solution
        :srcset: /tutorial/01_basic/solutions/images/sphx_glr_a_load_examples_solution_002.png
        :class: sphx-glr-single-img
     


   .. tab-item:: Interactive Scene



       .. offlineviewer:: /home/runner/work/pyvista-tutorial/pyvista-tutorial/doc/source/tutorial/01_basic/solutions/images/sphx_glr_a_load_examples_solution_002.vtksz






.. GENERATED FROM PYTHON SOURCE LINES 72-79

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-90

.. code-block:: Python


    dataset = examples.download_gears()
    bodies = dataset.split_bodies()
    bodies.plot(
        cmap="jet",
        multi_colors=True,
        smooth_shading=True,
        split_sharp_edges=True,
    )









.. tab-set::



   .. tab-item:: Static Scene



            
     .. image-sg:: /tutorial/01_basic/solutions/images/sphx_glr_a_load_examples_solution_003.png
        :alt: a load examples solution
        :srcset: /tutorial/01_basic/solutions/images/sphx_glr_a_load_examples_solution_003.png
        :class: sphx-glr-single-img
     


   .. tab-item:: Interactive Scene



       .. offlineviewer:: /home/runner/work/pyvista-tutorial/pyvista-tutorial/doc/source/tutorial/01_basic/solutions/images/sphx_glr_a_load_examples_solution_003.vtksz






.. GENERATED FROM PYTHON SOURCE LINES 91-104

Exercise #2 - Download and View a File
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Experiment on your own by downloading a dataset and reading it in with
:class:`pyvista.read`. You can use one of your own files or try downloading
one from the following sources:

- `Sample VTK DataSets <https://github.com/pyvista/vtk-data/tree/master/Data>`_
- `Sample STL files <https://www.amtekcompany.com/teaching-resources/stl-files/>`_
- `Thingiverse <https://www.thingiverse.com/>`_

**Solution**
Download the file ``'P_shelf_pin.stl'`` from
https://www.thingiverse.com/thing:5412753

.. GENERATED FROM PYTHON SOURCE LINES 104-108

.. code-block:: Python


    mesh = pv.read("P_shelf_pin.stl")
    mesh.plot()








.. tab-set::



   .. tab-item:: Static Scene



            
     .. image-sg:: /tutorial/01_basic/solutions/images/sphx_glr_a_load_examples_solution_004.png
        :alt: a load examples solution
        :srcset: /tutorial/01_basic/solutions/images/sphx_glr_a_load_examples_solution_004.png
        :class: sphx-glr-single-img
     


   .. tab-item:: Interactive Scene



       .. offlineviewer:: /home/runner/work/pyvista-tutorial/pyvista-tutorial/doc/source/tutorial/01_basic/solutions/images/sphx_glr_a_load_examples_solution_004.vtksz






.. GENERATED FROM PYTHON SOURCE LINES 109-116

.. raw:: html

    <center>
      <a target="_blank" href="https://colab.research.google.com/github/pyvista/pyvista-tutorial/blob/gh-pages/notebooks/tutorial/01_basic/solutions/a_load_examples_solution.ipynb">
        <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/ width="150px">
      </a>
    </center>


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 5.744 seconds)


.. _sphx_glr_download_tutorial_01_basic_solutions_a_load_examples_solution.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/solutions/a_load_examples_solution.ipynb
        :alt: Launch binder
        :width: 150 px

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: a_load_examples_solution.ipynb <a_load_examples_solution.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: a_load_examples_solution.py <a_load_examples_solution.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: a_load_examples_solution.zip <a_load_examples_solution.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
