I created a little model to show a disease could spread. I succeded in showing a different graph for each iteration but I would like to plot a single graph that gets updated at each iteration and shows how the particles move from one iteration to the other.
This is where i call the data i want to plot:
def plotter(population):
for people in population:
if people.status==0:
plt.scatter(people.positionx,people.positiony,c='b')
else:
if people.healthstatus==0:
plt.scatter(people.positionx,people.positiony,c='g')
if people.healthstatus==1:
plt.scatter(people.positionx,people.positiony,c='y')
if people.healthstatus==2:
plt.scatter(people.positionx,people.positiony,c='r')
this is the main where iterate the model
def main(iterations,populationsize):
popde=generator(populationsize)
population=popde[0]
dead=popde[1]
plt.ion()
for numit in range(iterations):
population=movement(population)
popde2=infection(population,populationsize,dead)
population=popde2[0]
dead=popde2[1]
populationsize=popde2[2]
plotter(population)
plt.pause(0.1)
plt.draw()
The code works perfectly fine, it's just a style issue
I tried looking for other solutions on the web but I couldn't the one that fits my problem. Thanks in advance to all those who will help!