Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to get and set rotation angle of 3D plot in Matplotlib

📅 2014-Oct-27 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ angle, azimuth, matplotlib, rotation ⬩ 📚 Archive

The rotation angle of the 3D plot in the X-Y plane can be get and set easily in Matplotlib. Its current value can be accessed from the azim property of Axes3D. It can be set using the view_init method of Axes3D.

This example shows how to get and set the rotation angle:

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# Get instance of Axis3D
fig = plt.figure()
ax = fig.gca(projection="3d")

# Get current rotation angle
print ax.azim

# Set rotation angle to 30 degrees

Tried with: Python 2.7.6 and Ubuntu 14.04

© 2023 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 Mastodon📧 Email