[英]Pyplot - '3D' scatter plot - zlabel?
最小工作示例:
#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軸的label如何設置? 由於某種原因,plt 具有 xlabel 和 ylabel 屬性,但沒有 zlabel。
對於 3D 圖,需要使用軸對象更改標簽。
嘗試這樣的事情
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.