开发者

matplotlib draw showing nothing

I'm using python's matplotlib to do some contours using contour and contourf functions. They all work fine when using show, but when I try to use draw() inside a method, I get the matplotlib window but not graph. The show() call will be done much later on the code and in a different method, and I would like to show one graph at the moment when it's done with draw(), not having to wait until the much later show(). What I'开发者_开发知识库m doing wrong?

Thanks.


Have you turned interactive mode on using ion()? The following works for me on OSX, using the Tk backend and running from the shell's command line:

import matplotlib.pyplot as plt

plt.ion()
plt.figure()
for i in range(10):
    plt.plot([i], [i], 'o')
    plt.draw()
raw_input("done >>")  

That is, as it does each loop, you see the plot change (i.e., it gets redrawn) as each point is added. Here, btw, if I instead call plt.ioff(), I don't see the figure or any updates.


IIRC ,You should be able call fig.show() multiple times. Also, check out using ipython (ipython -pylab) and http://matplotlib.sourceforge.net/users/shell.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜