.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "tutorial/00_intro/a_basic.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_00_intro_a_basic.py: .. _ref_geometric_example: Create Basic Geometric Objects ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is the "Hello, world!" of PyVista. .. GENERATED FROM PYTHON SOURCE LINES 9-12 .. code-block:: Python import pyvista as pv .. GENERATED FROM PYTHON SOURCE LINES 13-17 This runs through several of the available geometric objects available in VTK which PyVista provides simple convenience methods for generating. Let's run through creating a few geometric objects! .. GENERATED FROM PYTHON SOURCE LINES 17-28 .. code-block:: Python cyl = pv.Cylinder() arrow = pv.Arrow() sphere = pv.Sphere() plane = pv.Plane() line = pv.Line() box = pv.Box() cone = pv.Cone() poly = pv.Polygon() disc = pv.Disc() .. GENERATED FROM PYTHON SOURCE LINES 29-30 Now let's plot them all in one window .. GENERATED FROM PYTHON SOURCE LINES 30-58 .. code-block:: Python p = pv.Plotter(shape=(3, 3)) # Top row p.subplot(0, 0) p.add_mesh(cyl, color="tan", show_edges=True) p.subplot(0, 1) p.add_mesh(arrow, color="tan", show_edges=True) p.subplot(0, 2) p.add_mesh(sphere, color="tan", show_edges=True) # Middle row p.subplot(1, 0) p.add_mesh(plane, color="tan", show_edges=True) p.subplot(1, 1) p.add_mesh(line, color="tan", line_width=3) p.subplot(1, 2) p.add_mesh(box, color="tan", show_edges=True) # Bottom row p.subplot(2, 0) p.add_mesh(cone, color="tan", show_edges=True) p.subplot(2, 1) p.add_mesh(poly, color="tan", show_edges=True) p.subplot(2, 2) p.add_mesh(disc, color="tan", show_edges=True) # Render all of them p.show() # Export this plotter as an interactive scene to a HTML file. # p.export_html("a_basic.html") .. image-sg:: /tutorial/00_intro/images/sphx_glr_a_basic_001.png :alt: a basic :srcset: /tutorial/00_intro/images/sphx_glr_a_basic_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 59-66 .. raw:: html
Open In Colab
.. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.946 seconds) .. _sphx_glr_download_tutorial_00_intro_a_basic.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/00_intro/a_basic.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: a_basic.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: a_basic.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_