matplotlib circle, animation, how to remove old circle in animation

后端 未结 2 542
感情败类
感情败类 2020-12-19 13:59

I am trying to simulate an animation of a circular shock wave from a selected data point using Matplotlib\'s circle and animation. But I couldn\'t figure out a way to remov

2条回答
  •  鱼传尺愫
    2020-12-19 14:59

    Add this code to your animate function:

    for obj in ax.findobj(match = type(plt.Circle(1, 1))):
      obj.remove()
    

    ax.findobj(match = type(plt.Circle(1, 1))) looks for all the circle patches on the axes, which you can then remove before plotting a new circle. I used plt.Circle() to make a circle object to match -- the arguments you pass it don't really matter.

提交回复
热议问题