所有栏目 | 云社区 美国云服务器[国内云主机商]
你的位置:首页 > 云社区 » 正文

Python如何实现数据动态化?

发布时间:2020-04-12 08:44:47

资讯分类:动态化  python  坐标轴  xy  动画  有了  可以用
Python如何实现数据动态化?

Python有些出色的数据可视化库,但很少能渲染GIF或视频动画。本文介绍如何运用MoviePy作为其他库的通用动画插件。

有了 MoviePy ,你可以用一个函数 make_frame(t) 自定义动画,并返回相应的时间t的视频帧(秒):

Python
1
2
3
4
5
6
7
8
9
10
11
12
from moviepy.editor import VideoClip
def make_frame(t):
""" returns an image of the frame at time t """
# ... create the frame with any library
return frame_for_time_t # (Height x Width x 3) Numpy array
animation = VideoClip(make_frame, duration=3) # 3-second clip
# For the export, many options/formats/optimizations are supported
animation.write_videofile("my_animation.mp4
留言与评论(共有 0 条评论)
   
验证码:
Top