{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Linked Views in Subplots {#linked_views_example}\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\n\nimport pyvista as pv\nfrom pyvista import examples\n\npv.set_plot_theme(\"document\")\n\n# download mesh\nmesh = examples.download_cow()\n\ndecimated = mesh.decimate_boundary(target_reduction=0.75)\n\np = pv.Plotter(shape=(1, 2), border=False)\np.subplot(0, 0)\np.add_text(\"Original mesh\", font_size=24)\np.add_mesh(mesh, show_edges=True, color=True)\np.subplot(0, 1)\np.add_text(\"Decimated version\", font_size=24)\np.add_mesh(decimated, color=True, show_edges=True)\n\np.link_views() # link all the views\n# Set a camera position to all linked views\np.camera_position = [(15, 5, 0), (0, 0, 0), (0, 1, 0)]\n\np.open_gif(\"linked.gif\")\n# Update camera and write a frame for each updated position\nnframe = 15\nfor i in range(nframe):\n p.camera_position = [\n (15 * np.cos(i * np.pi / 45.0), 5.0, 15 * np.sin(i * np.pi / 45.0)),\n (0, 0, 0),\n (0, 1, 0),\n ]\n p.write_frame()\n\n# Close movie and delete object\np.close()" ] } ], "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 }