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

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
ax.view_init(azim=30)

Tried with: Python 2.7.6 and Ubuntu 14.04

Advertisements

One thought on “How to get and set rotation angle of 3D plot in Matplotlib”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s