Files
coronavis/all_countries.py
2020-06-24 13:45:27 +02:00

32 lines
1.1 KiB
Python

"""
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)