[英]Animation of points in Python (matplotlib)
I have a given list with points (x, y), which changes during the course of the given function, for example: arr = [(1, 2), (1, 3), (5, 6), (8, 1)]
, which is the coordinates of the points (1, 2), (1, 3), (5, 6), (8, 1)我有一个带有点 (x, y) 的给定列表,它在给定 function 的过程中会发生变化,例如:
arr = [(1, 2), (1, 3), (5, 6), (8, 1)]
,即点 (1, 2), (1, 3), (5, 6), (8, 1) 的坐标
for i in range (5):
arr = function (arr) # different array
After each loop, I would like to draw a graph of coordinates with marked points, ie I want to create an animation from it.在每个循环之后,我想绘制一个带有标记点的坐标图,即我想从中创建一个 animation。 How can this be done in Python?
如何在 Python 中做到这一点?
I would say do not plot them in any loop.我想说不要在任何循环中 plot 它们。 Just accumulate all those values, pass it to whatever plotting library you are using (
matplotlib
does have animation support).只需累积所有这些值,将其传递给您正在使用的任何绘图库(
matplotlib
确实支持 animation )。 Take a look here: https://matplotlib.org/3.3.3/api/animation_api.html看看这里: https://matplotlib.org/3.3.3/api/animation_api.html
If your data is streaming, maybe use some time windows.如果您的数据是流式传输的,可能需要一些时间 windows。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.