Files
coronavis/death_per_case.py
2020-12-21 12:04:37 +01:00

26 lines
863 B
Python

"""
Plot total deaths per total cases of countries over time on log scale
"""
import matplotlib.pyplot as pp
import numpy as np
name="death_per_case"
def plot(data, countries, pop, **kwargs):
figsize = (10,5)
for loc in data:
if loc not in countries:
continue
time, new_cases, new_deaths, total_cases, total_deaths, total_vaccinations = data[loc]['time'], data[loc]['new_cases'], data[loc]['new_deaths'], data[loc]['total_cases'], data[loc]['total_deaths'], data[loc]['total_vaccinations']
# death/case
pp.figure(name, figsize=figsize)
pp.plot(time, np.array(total_deaths)/np.array(total_cases), label=f"{loc}", marker=".")
pp.yscale("log")
pp.ylabel("relative deaths")
pp.xticks(rotation=45)
pp.legend(frameon=False)
pp.tight_layout()
pp.savefig("img/"+name+".png")