Benutzer-Werkzeuge

Webseiten-Werkzeuge


Seitenleiste

ws2021:code7
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import math
import Code5
 
x_data = []
y_data = []
 
print(infected_list)
 
"""
class matplotlib.animation.FuncAnimation(fig, func,
    frames=None, init_func=None, save_count=None, *, cache_frame_data=True, **kwargs)
"""
fig, ax = plt.subplots()
ax.set_xlim(0, len(infected_list))
ax.set_ylim(0, len(agents))
line, = ax.plot(0,0)
 
def animation_frame(i):
    x_data.append(i)
    #y_data.append(i)
    y_data.append(infected_list[i])
    #y_data.append(agents.length)
 
 
    line.set_xdata(x_data)
    line.set_ydata(y_data)
    return line,
 
 
 
animation = FuncAnimation(fig, func=animation_frame, frames=np.arange(0, 50, 1), interval=10)
plt.show()
ws2021/code7.txt · Zuletzt geändert: 2021/01/29 13:47 von n.gujejiani