.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/mplot3d/wire3d_animation_sgskip.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. meta:: :keywords: codex .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_mplot3d_wire3d_animation_sgskip.py: =========================== Animate a 3D wireframe plot =========================== A very simple "animation" of a 3D plot. See also :doc:`rotate_axes3d_sgskip`. (This example is skipped when building the documentation gallery because it intentionally takes a long time to run.) .. GENERATED FROM PYTHON SOURCE LINES 11-42 .. code-block:: Python import time import matplotlib.pyplot as plt import numpy as np fig = plt.figure() ax = fig.add_subplot(projection='3d') # Make the X, Y meshgrid. xs = np.linspace(-1, 1, 50) ys = np.linspace(-1, 1, 50) X, Y = np.meshgrid(xs, ys) # Set the z axis limits, so they aren't recalculated each frame. ax.set_zlim(-1, 1) # Begin plotting. wframe = None tstart = time.time() for phi in np.linspace(0, 180. / np.pi, 100): # If a line collection is already remove it before drawing. if wframe: wframe.remove() # Generate data. Z = np.cos(2 * np.pi * X + phi) * (1 - np.hypot(X, Y)) # Plot the new wireframe and pause briefly before continuing. wframe = ax.plot_wireframe(X, Y, Z, rstride=2, cstride=2) plt.pause(.001) print('Average FPS: %f' % (100 / (time.time() - tstart))) .. _sphx_glr_download_gallery_mplot3d_wire3d_animation_sgskip.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: wire3d_animation_sgskip.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: wire3d_animation_sgskip.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_