如何在 Mplot3d 中縮放軸?


若要在 mplot3d 中縮放軸,我們可以執行以下步驟 -

  • 使用 figure() 方法建立圖形或啟用現有圖形。

  • 使用Axes3D()類例項化 3D 軸例項。

  • 若要縮放 X 軸,請使用set_xlim3d()方法。

  • 若要縮放 Y 軸,請使用set_ylim3d()方法。

  • 若要縮放 Z 軸,請使用set_zlim3d()方法。

  • 若要顯示該圖,請使用show() 方法。

示例

from mpl_toolkits.mplot3d import Axes3D
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
fig = plt.figure()
ax = Axes3D(fig)
ax.set_xlim3d(-100, 100)
ax.set_ylim3d(-100, 100)
ax.set_zlim3d(-100, 100)
plt.show()

輸出

更新於: 2021 年 5 月 12 日

4K+ 瀏覽量

開啟你的 職業生涯

完成課程獲取認證

開始吧
廣告
© . All rights reserved.