1

I found an interesting animation of a particle system that I would like to implement on jupyter notebook. So I copied the code in the file collision.py and pasted it on my jupyter notebook. After executing the code I am getting only a static picture

enter image description here

I tried to include the magic command %matplotlib inline but it still does not work. Does someone know why?

tester931
  • 47
  • 4

2 Answers2

1

You need to save it as a gif file. Then open it in jupyter notebook

Elvin Jafarov
  • 1,341
  • 11
  • 25
  • I don't know Jupyter notebook but I highly doubt that this is the only way to use FuncAnimation. – Mr. T Jan 27 '21 at 13:00
1

When I run the code you showed, collision.mp4 will be saved locally and I can play it as an animation. If you want to run the animation in jupyter environment, you need to install the following code.

# Jupyter lab
from IPython.display import HTML
%matplotlib inline

(Omission)

# plt.show()

# jupyter lab 
plt.close()
HTML(anim.to_html5_video())

This is just one example of what I do. Please try this SO answer as it is very helpful.

r-beginners
  • 31,170
  • 3
  • 14
  • 32