matplotlib cla() 问题
我正在尝试使用 matplotlib 制作一些动画。
fig = plt.figure()
ax = fig.gca(projection='3d')
...
for k in xrange(10):
...
ax.cla()
ax.plot_surface(X, Y, field.real, rstride=2, cstride=2, cmap=cm.hot,
linewidth=0, antialiased=False)
ax.set_zlim3d(-50, 150)
filename = "out_%d.png" % k
fig.savefig(filename)
...
起初我没有使用 cla(),所以在每次迭代中我都得到相同的图片(http://dl.dropbox.com/u/4988243/out_0.png)。当我添加 ax.cla() 时,动画没问题,但我得到了一些不需要的轴,我不知道如何摆脱它们(http://dl.dropbox.com/u/4988243/out_1.png)。
i am trying to make some animation using matplotlib.
fig = plt.figure()
ax = fig.gca(projection='3d')
...
for k in xrange(10):
...
ax.cla()
ax.plot_surface(X, Y, field.real, rstride=2, cstride=2, cmap=cm.hot,
linewidth=0, antialiased=False)
ax.set_zlim3d(-50, 150)
filename = "out_%d.png" % k
fig.savefig(filename)
...
at first i didn't use cla(), so on every iteration i got the same picture (http://dl.dropbox.com/u/4988243/out_0.png). when i added ax.cla() it was ok with animation but i got some unwanted axes which i don't know how to get rid of (http://dl.dropbox.com/u/4988243/out_1.png).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在 ubuntu 11.04 上运行来自 github 的最新版本的 Matplotlib。我编写了一个代码片段,每次都会创建一个新的轴实例,这似乎会生成您想要的轴完整的图。您看到的问题可能只是一个错误,但我认为这可以解决它。我绘制了随机数图,仅用于演示目的。
I'm running the latest version of Matplotlib from github on ubuntu 11.04. I wrote a code snippet where I create a new axis instance each time, and this seems to produce the plots that you want with axis intact. The problem you're seeing might just be a bug, but I think this works around it. I made plots of random numbers, just for demonstration purposes.