{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Geometric Objects {#geometric_example}\n\nThe \\\"Hello, world!\\\" of VTK. Uses objects from\n`geometry_api`{.interpreted-text role=\"ref\"}.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import pyvista as pv" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This runs through several of the available geometric objects available\nin VTK which PyVista provides simple convenience methods for generating.\n\nLet\\'s run through creating a few geometric objects.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "cyl = pv.Cylinder()\narrow = pv.Arrow()\nsphere = pv.Sphere()\nplane = pv.Plane()\nline = pv.Line()\nbox = pv.Box()\ncone = pv.Cone()\npoly = pv.Polygon()\ndisc = pv.Disc()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now let\\'s plot them all in one window\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "p = pv.Plotter(shape=(3, 3))\n# Top row\np.subplot(0, 0)\np.add_mesh(cyl, color='lightblue', show_edges=True)\np.subplot(0, 1)\np.add_mesh(arrow, color='lightblue', show_edges=True)\np.subplot(0, 2)\np.add_mesh(sphere, color='lightblue', show_edges=True)\n# Middle row\np.subplot(1, 0)\np.add_mesh(plane, color='lightblue', show_edges=True)\np.subplot(1, 1)\np.add_mesh(line, color='lightblue', line_width=3)\np.subplot(1, 2)\np.add_mesh(box, color='lightblue', show_edges=True)\n# Bottom row\np.subplot(2, 0)\np.add_mesh(cone, color='lightblue', show_edges=True)\np.subplot(2, 1)\np.add_mesh(poly, color='lightblue', show_edges=True)\np.subplot(2, 2)\np.add_mesh(disc, color='lightblue', show_edges=True)\n# Render all of them\np.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.2" } }, "nbformat": 4, "nbformat_minor": 0 }