我在Python语言中有三个数据点列表xs,ys,zs,我正在尝试使用scatter3d方法用matplotlib创建3d绘图。
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
plt.xlim(290)
plt.ylim(301)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.scatter(xs, ys, zs)
plt.savefig('dateiname.png')
plt.close()plt.xlim()和plt.ylim()运行良好,但我找不到在z方向上设置边界的函数。我如何做到这一点呢?
发布于 2016-05-30 17:34:28
只需使用axes对象的set_zlim函数(就像您已经对set_zlabel所做的那样,它也不能作为plt.zlabel使用):
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
xs = np.random.random(10)
ys = np.random.random(10)
zs = np.random.random(10)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.scatter(xs, ys, zs)
ax.set_zlim(-10,10)https://stackoverflow.com/questions/37521910
复制相似问题