Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update the "Rotating a 3D plot" gallery example to show all 3 rotation axes#21737

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall 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 deletionsexamples/mplot3d/rotate_axes3d_sgskip.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionsexamples/mplot3d/wire3d_animation_sgskip.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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

[8]ページ先頭

©2009-2025 Movatter.jp