最接近的解決view_init
直接設置ax.dist
。根據get_proj
的文檔「dist是眼睛觀察點距目標點的距離」。 initial value is currently hardcoded與dist = 10
。較低的值(大於0!)將導致放大繪圖。
注意:此行爲沒有真正記錄並可能會更改。在大多數情況下,更改軸的極限以僅繪製相關部件可能是更好的解決方案。您可以使用ax.autoscale(tight=True)
來方便地執行此操作。
工作IPython的/ Jupyter例如:
%matplotlib inline
from IPython.display import display
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# Grab some test data.
X, Y, Z = axes3d.get_test_data(0.05)
# Plot a basic wireframe.
ax.view_init(90, 0)
ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)
plt.close()
from ipywidgets import interact
@interact(dist=(1, 20, 1))
def update(dist=10):
ax.dist = dist
display(fig)
輸出
dist = 10
dist = 5
來源
2017-06-27 00:38:25
Jan