最小作業示例:
#Python
import matplotlib.pyplot as plt
x = [0, 1, 2, 3, 4, 5]
y = [0, 1, 2, 3, 4, 5]
z = [0, 1, 2, 3, 4, 5]
fig = plt.figure()
ax = plt.axes(projection="3d")
ax.scatter(x, y, z, c='g', s=20)
plt.xlabel("X data")
plt.ylabel("Y data")
#plt.zlabel("Z data") DOES NOT WORK
ax.view_init(60,35)
plt.show()
問題:如何設定Z軸的標簽?由于某種原因 plt 具有 xlabel 和 ylabel 屬性,但沒有 zlabel。
uj5u.com熱心網友回復:
對于 3D 繪圖,需要使用軸物件更改標簽。
嘗試這樣的事情
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/532952.html
上一篇:無法使用zip方法替換子字串
