vaccination state corrected (first vs second dose), small cleanup

This commit is contained in:
fordprefect
2021-02-17 13:50:18 +01:00
parent aa8faf634e
commit 15784f7e72
3 changed files with 43 additions and 31 deletions

View File

@@ -34,7 +34,8 @@ def plot(data, countries, pop, metadata={}, **kwargs):
continue
name = basename+loc
time, new_cases, new_deaths, total_cases, total_deaths, total_vaccinations, stringency_index, new_vaccinations = data[loc]['time'], data[loc]['new_cases'], data[loc]['new_deaths'], data[loc]['total_cases'], data[loc]['total_deaths'], data[loc]['total_vaccinations'], data[loc]['stringency_index'], data[loc]['new_vaccinations']
people_fully_vaccinated = data[loc]['people_fully_vaccinated']
fig, ax1 = pp.subplots(num=name, figsize=figsize)
@@ -54,19 +55,8 @@ def plot(data, countries, pop, metadata={}, **kwargs):
if np.isnan(total_vaccinations[-2]):
print(f"{loc} starts vaccinating, adding to plot")
ax2.plot(time, np.array(total_vaccinations), label=f"Total vaccinations", marker="", linestyle="-.", color="crimson")
if False:
# plot detailed vaccination plot for all_countries.py
rfig, rax = pp.subplots(1,1,num=f"{loc}_vacc")
rax2 = rax.twinx()
rax.plot(time, new_vaccinations, linestyle="--", color="green", label="new vac")
rax2.plot(time, total_vaccinations, linestyle="-.", color="red", label="total vac")
rax.set_ylabel("new vaccinatios")
rax2.set_ylabel("total vaccinations")
rax.legend(frameon=False, loc=2)
rfig.savefig("img/"+f"{loc}".replace(" ", "_").replace("'", "").replace("/", "") + "/vaccs.png")
ax2.plot(time, np.array(total_vaccinations), label=f"Total vaccination doses", marker="", linestyle="-.", color="crimson")
ax2.plot(time, np.array(people_fully_vaccinated), label="fully vaccinated", marker="", linestyle="-", color="crimson")
# fix lower bound of plot
for ax in (ax1, ax2):
@@ -145,9 +135,9 @@ def plot(data, countries, pop, metadata={}, **kwargs):
if loc in pop:
#pp.title(f"{loc}", population = "+f"{pop[loc]['pop']:,}".replace(",","."))
title += ", population = "+f"{pop[loc]['pop']:,}".replace(",",".")
if not np.isnan(total_vaccinations[-1]):
title += ", vac rate: "+f"{total_vaccinations[-1]/pop[loc]['pop']*100:1.3f}%"
vaccs.append([loc, total_vaccinations[-1], total_vaccinations[-1]/pop[loc]['pop']*100]) # bookkeeping for overview
if not np.isnan(people_fully_vaccinated[-1]):
title += ", vac rate: "+f"{people_fully_vaccinated[-1]/pop[loc]['pop']*100:1.3f}%"
vaccs.append([loc, people_fully_vaccinated[-1], people_fully_vaccinated[-1]/pop[loc]['pop']*100]) # bookkeeping for overview
ax1.set_title(title)
fig.tight_layout()
pp.text(0.002,0.005, f"plot generated {time_module.strftime('%Y-%m-%d %H:%M')}, CC-by-sa-nc, origin: dukun.de/corona, datasource: ourworldindata.org/coronavirus-source-data", color="dimgrey", fontsize=8, transform=fig.transFigure)
@@ -167,7 +157,7 @@ def plot(data, countries, pop, metadata={}, **kwargs):
# data
for loc, tvac, rvac in vaccs:
line = f"<tr><td>{loc}</td><td>" + \
f"{tvac:,d}".replace(",",".") + \
f"{int(tvac):,d}".replace(",",".") + \
f"</td><td>{rvac:3.3f}%</td>".replace(".", ",")
if "vaccines" in metadata[loc]:
line += f"<td>{metadata[loc]['vaccines']}</td></tr>\n"