在matplotlib中绘制和cla

时间:2016-05-19 10:03:23

标签: python matplotlib plot

我正在使用matplotlib pyplot arrow函数绘制多个箭头。它的发布很好。在绘制了一组箭头后,我需要重新计算箭头位置并再次绘制它们。我正在使用draw。所以基本上我在循环中绘制并绘制箭头,并在一段时间后使用cla()清除绘图。这是我不明白的:当我用time.sleep(1)函数替换等待键输入的raw_input()时,它工作得很好,但是当我使用time.sleep(1)时根本没有显示情节。

这是我的代码(我已经删除了一些可能无关的东西):

import matplotlib.pyplot as PP
import time
fig = PP.figure()
fig.show()
ax = fig.add_subplot(111)   
for i in range(30):
    for i in range(100):
      pass
      # loc = some code to recalculate arrow locations
    for x,y in loc.iteritems():
        ax.arrow( x, y,.05,.05, fc="k", ec="k",head_width=0.04, head_length=0.04 )
    PP.draw()
    #raw_input()
    time.sleep(1)
    PP.cla()

0 个答案:

没有答案