plot infections in all countries
This commit is contained in:
31
all_countries.py
Normal file
31
all_countries.py
Normal file
@@ -0,0 +1,31 @@
|
||||
"""
|
||||
Plot overview plot for each country separately
|
||||
"""
|
||||
import matplotlib.pyplot as pp
|
||||
import numpy as np
|
||||
basename="all_"
|
||||
|
||||
def plot(data, countries):
|
||||
figsize = (10,5)
|
||||
for loc in data:
|
||||
name = basename+loc
|
||||
time, new_cases, new_deaths, total_cases, total_deaths = data[loc]
|
||||
|
||||
fig, ax1 = pp.subplots(num=name, figsize=figsize)
|
||||
|
||||
ax1.plot(time, new_cases, label="raw new cases", color="grey", linestyle="-")
|
||||
ax1.plot(time[3:-3], np.convolve(new_cases, np.ones((7,))/7, mode="valid"), label="new cases 7day mean", color="orange", linestyle="-", linewidth=2)
|
||||
|
||||
ax2 = ax1.twinx()
|
||||
ax2.plot(time, total_cases, label=f"Total cases", marker="", linestyle="--", color="blue")
|
||||
|
||||
#ax1.xticks(rotation=45)
|
||||
#ax1.set_xlabel("date")
|
||||
ax1.set_ylabel("new cases")
|
||||
ax2.set_ylabel("total cases")
|
||||
fig.legend(frameon=False, loc="upper left", bbox_to_anchor=(0,1), bbox_transform=ax1.transAxes)
|
||||
pp.title(loc)
|
||||
fig.tight_layout()
|
||||
|
||||
pp.savefig("ac_"+name+".png")
|
||||
pp.close(fig)
|
||||
Reference in New Issue
Block a user