Ich habe 3D-Plot-Oberfläche. Und ich möchte die vertikale Kameradrehung für diese Handlung deaktivieren.Wie deaktivieren Sie die vertikale Kameradrehung für 3D-Plot in Matplotlib?
0
A
Antwort
1
Standardmäßig können Sie nur die Maus für Ihr Grundstück deaktivieren:
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()
1
Meine Lösung:
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)