4

I have 3d plot surface. And I want disable vertical camera rotation for this plot.

3 Answers 3

2

By default you may only disable mouse for your plot:

from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
X, Y, Z = axes3d.get_test_data(0.1)
# disable mouse
ax.disable_mouse_rotation()
ax.plot_wireframe(X, Y, Z, rstride=5, cstride=5)
# set start rotation 
ax.view_init(30, 120)
plt.show()
Sign up to request clarification or add additional context in comments.

Comments

2

My solution:

def disable_vert_rotation(event):
    azim = ax.azim
    ax.view_init(elev=0, azim=azim)


fig.canvas.mpl_connect('motion_notify_event', disable_vert_rotation)

Comments

0

This may be relevant:
https://matplotlib.org/stable/api/toolkits/mplot3d/view_angles.html#rotation-with-mouse

I found that using the azel mouse rotation style would constraint the plot to stay upright. If that's what you meant by disabling vertical camera rotation.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.