Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions examples/mplot3d/rotate_axes3d_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Rotating a 3D plot
==================

A very simple animation of a rotating 3D plot.
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.

Expand All @@ -17,12 +17,34 @@
fig = plt.figure()
ax = fig.add_subplot(projection='3d')

# load some test data for demonstration and plot a wireframe
X, Y, Z = axes3d.get_test_data(0.1)
ax.plot_wireframe(X, Y, Z, rstride=5, cstride=5)
# Grab some example data and plot a basic wireframe.
X, Y, Z = axes3d.get_test_data(0.05)
ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)

# Set the axis labels
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')

# Rotate the axes and update
for angle in range(0, 360*4 + 1):
# Normalize the angle to the range [-180, 180] for display
angle_norm = (angle + 180) % 360 - 180

# Cycle through a full rotation of elevation, then azimuth, roll, and all
elev = azim = roll = 0
if angle <= 360:
elev = angle_norm
elif angle <= 360*2:
azim = angle_norm
elif angle <= 360*3:
roll = angle_norm
else:
elev = azim = roll = angle_norm

# Update the axis view and title
ax.view_init(elev, azim, roll)
plt.title('Elevation: %d°, Azimuth: %d°, Roll: %d°' % (elev, azim, roll))

# rotate the axes and update
for angle in range(0, 360):
ax.view_init(30, angle, 0)
plt.draw()
plt.pause(.001)
6 changes: 3 additions & 3 deletions examples/mplot3d/wire3d_animation_sgskip.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
==========================
Rotating 3D wireframe plot
==========================
=============================
Animating a 3D wireframe plot
=============================

A very simple 'animation' of a 3D plot. See also rotate_axes3d_demo.

Expand Down