【发布时间】:2022-12-05 22:26:10
【问题描述】:
我是 python 的新手。我必须在不同的时间迭代绘制一些数据。该图是一个 3d 散点图。该图有一些我想修复的错误:查看三个不同时间实例(第一个、中间和最后一个)的图
- 如您所见,每个图像周围都有一个框,被标题“图表标题”截断了。我想删除这条框线(我不明白它来自哪里)。注意我想保留轴标题。
- 在中间和最后一张图片中,坐标轴上的数字似乎重叠,我只想为每张图片固定三个轴中的每一个。
如何编辑我的代码来执行上述操作。
fig, ax = plt.subplots()
for n in range(10):
#labels
ax=plt.axes(projection='3d')
ax.set_title('graph title')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
ax.set_xlim(left=-10, right=20)
ax.set_ylim(bottom=-10, top=20)
ax.set_zlim(bottom=-10, top=20)
#plotting
x=data[n]
ax.scatter(x[:,0],x[:,1],x[:,2])
plt.savefig(f'fig_{n}.png')
plt.cla() # needed to remove the plot because savefig doesn't clear it
【问题讨论】:
标签: python matplotlib axis subplot axis-labels