Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
215 views
in Technique[技术] by (71.8m points)

python - Animation shows only a static picture - jupyter notebook

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?

question from:https://stackoverflow.com/questions/65919490/animation-shows-only-a-static-picture-jupyter-notebook

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...