您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

matplotlib圆,动画,如何删除动画中的旧圆

matplotlib圆,动画,如何删除动画中的旧圆

我认为您set_radius每次都可以用来更改圆圈大小:

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation


testData = np.random.rand(100,2)-[0.5, 0.5]

fig, ax = plt.subplots()
circle1=plt.Circle(testData[20,:],0,color='r',fill=False, clip_on = False)
ax.add_artist(circle1)
# i is the radius
def animate(i):
    #init()
    #you don't want to redraw the same dots over and over again, do you?
    circle1.set_radius(i)


def init():
    sctPlot, = ax.plot(testData[:,0], testData[:,1], ".")
    return sctPlot,

ani = animation.FuncAnimation(fig, animate, np.arange(0.4, 2, 0.1), init_func=init,
    interval=25, blit=False)
plt.show()

因此,您不必每次都删除和重绘补丁,我认为这样做可能更有效。

其他 2022/1/1 18:25:36 有422人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶