Skip to content

Commit

Permalink
Link 3D animation examples to one another.
Browse files Browse the repository at this point in the history
Also use double quotes in English text.
Also inline definition of Z array; it's not as the docstring of
generate() was helpful at all.
  • Loading branch information
anntzer committed Jul 8, 2022
1 parent 79b7f25 commit 02b07ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/mplot3d/rotate_axes3d_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
A very simple animation of a rotating 3D plot about all 3 axes.
See wire3d_animation_demo for another simple example of animating a 3D plot.
See :doc:`wire3d_animation_sgskip` for another example of animating a 3D plot.
(This example is skipped when building the documentation gallery because it
intentionally takes a long time to run)
Expand Down
14 changes: 3 additions & 11 deletions examples/mplot3d/wire3d_animation_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Animating a 3D wireframe plot
=============================
A very simple 'animation' of a 3D plot. See also rotate_axes3d_demo.
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)
Expand All @@ -14,14 +14,6 @@
import time


def generate(X, Y, phi):
"""
Generates Z data for the points in the X, Y meshgrid and parameter phi.
"""
R = 1 - np.sqrt(X**2 + Y**2)
return np.cos(2 * np.pi * X + phi) * R


fig = plt.figure()
ax = fig.add_subplot(projection='3d')

Expand All @@ -40,9 +32,9 @@ def generate(X, Y, phi):
# 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.
Z = generate(X, Y, phi)
wframe = ax.plot_wireframe(X, Y, Z, rstride=2, cstride=2)
plt.pause(.001)

Expand Down

0 comments on commit 02b07ef

Please sign in to comment.