Updating a figure

Hello everyone, this is my very first post here. I am encountering a problem using plt.pause. I am trying to imitate the procedure in this video. I follow his code line by line, but the results are different. I get multiple figures generated to update the plot, while he gets only one figure updated. Can anyone explain why this is happening and how to avoid it? Thank you.

Well, technically you are not following the video because you’re using a jupyter notebook.

Instead, use a script.

For more details about Matplotlib within jupyter notebooks, see this post

Thank you for the clarification. It redirected me to the right way. I managed to solve the problem, just used clear output, but I didn’t understand why it has been fixed :sweat_smile:. I guess it was not a Matplotlib backend problem. If you might have any idea explaining why it worked, I would be thankful.

The issue is that you are using the inline backend which only renders “dead” pngs of the figure so anything that updates the figure and then redisplays it will not work.

I suggest installing ipympl — ipympl and using %matplotlib widget