refactor
This commit is contained in:
24
normalized_to_first_death.py
Normal file
24
normalized_to_first_death.py
Normal file
@@ -0,0 +1,24 @@
|
||||
"""
|
||||
Plot total cases timeshiftet to first death
|
||||
"""
|
||||
import matplotlib.pyplot as pp
|
||||
import numpy as np
|
||||
name="normalized_to_first_death"
|
||||
|
||||
def plot(data, countries):
|
||||
for loc in data:
|
||||
if loc not in countries:
|
||||
continue
|
||||
time, new_cases, new_deaths, total_cases, total_deaths = data[loc]
|
||||
|
||||
pp.figure(name)
|
||||
day_of_first_death = np.argwhere(np.array(total_deaths) > 0)[0][0]
|
||||
new_time_axis = np.arange(len(time)) - day_of_first_death
|
||||
pp.plot(new_time_axis, np.array(total_cases), label=f"{loc}")
|
||||
|
||||
pp.yscale("log")
|
||||
pp.xticks(rotation=90)
|
||||
pp.legend(frameon=False)
|
||||
pp.tight_layout()
|
||||
|
||||
pp.savefig(name+".png")
|
||||
Reference in New Issue
Block a user