Animation 如何为零时间绘制暂停()?

Animation 如何为零时间绘制暂停()?,animation,matplotlib,draw,show,pause,Animation,Matplotlib,Draw,Show,Pause,我正在画一个圆圈的动画。只要speed设置为正数,它看起来和工作起来都很好。但是,我想将速度设置为0.0。当我这样做的时候,有些东西改变了,不再有动画了。相反,我必须在每帧之后单击窗口上的“x”。我尝试使用plt.draw()和plt.show()的组合来获得与plt.pause()相同的效果,但帧没有显示出来。如何在不使用计时器或将其设置为0.0的情况下精确复制plt.pause()的功能 speed = 0.0001 plt.ion() for i in range(timesteps):

我正在画一个圆圈的动画。只要
speed
设置为正数,它看起来和工作起来都很好。但是,我想将
速度设置为
0.0
。当我这样做的时候,有些东西改变了,不再有动画了。相反,我必须在每帧之后单击窗口上的“x”。我尝试使用
plt.draw()
plt.show()
的组合来获得与
plt.pause()
相同的效果,但帧没有显示出来。如何在不使用计时器或将其设置为
0.0
的情况下精确复制
plt.pause()
的功能

speed = 0.0001
plt.ion()
for i in range(timesteps):
    fig, ax = plt.subplots()
    for j in range(num):
        circle = plt.Circle(a[j], b[j]), r[j], color='b')
        fig.gca().add_artist(circle)
    plt.pause(speed)
    #plt.draw()
    #plt.show()
    plt.clf()
    plt.close()

我已将
pyplot.pause()的代码复制到此处:

def pause(interval):
    """
    Pause for *interval* seconds.

    If there is an active figure it will be updated and displayed,
    and the GUI event loop will run during the pause.

    If there is no active figure, or if a non-interactive backend
    is in use, this executes time.sleep(interval).

    This can be used for crude animation. For more complex
    animation, see :mod:`matplotlib.animation`.

    This function is experimental; its behavior may be changed
    or extended in a future release.

    """
    backend = rcParams['backend']
    if backend in _interactive_bk:
        figManager = _pylab_helpers.Gcf.get_active()
        if figManager is not None:
            canvas = figManager.canvas
            canvas.draw()
            show(block=False)
            canvas.start_event_loop(interval)
            return

    # No on-screen figure is active, so sleep() is all we need.
    import time
    time.sleep(interval)
如您所见,它调用,这将启动一个单独的原始事件循环,时间间隔为
秒。如果
interval
==0似乎依赖于后端,会发生什么情况。例如,对于WX后端,值为0意味着这个循环是阻塞的,永远不会结束(我必须在这里查看,它没有出现在文档中。请参阅第773行)

简而言之,0是一个特例。您不能将其设置为较小的值,例如0.1秒吗

上面的
pause
docstring说明它只能用于原始数据,如果您想要更复杂的数据,您可能必须求助于