add vaccination state: data fetched in all_countries and included in index
This commit is contained in:
@@ -25,6 +25,8 @@ corr = {"Chile": 10000,
|
||||
|
||||
def plot(data, countries, pop, **kwargs):
|
||||
figsize = (10,5)
|
||||
|
||||
vaccs = []
|
||||
|
||||
for loc in data:
|
||||
try:
|
||||
@@ -136,6 +138,7 @@ def plot(data, countries, pop, **kwargs):
|
||||
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
|
||||
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)
|
||||
@@ -144,3 +147,13 @@ def plot(data, countries, pop, **kwargs):
|
||||
pp.close(fig)
|
||||
except Exception as e:
|
||||
print(f"=====> plotting failed for {loc}, skipping plot. Error: {e}")
|
||||
|
||||
## vaccination overview html
|
||||
with open("vac_state.html", "w") as f:
|
||||
# header
|
||||
f.write("<table><tr><th>Land</th><th>Impfungen</th><th>Impfrate</th></tr>\n")
|
||||
# data
|
||||
for loc, tvac, rvac in vaccs:
|
||||
f.write(f"<tr><td>{loc}</td><td>" + f"{tvac:,d}".replace(",",".") + f"</td><td>{rvac:3.3f}%</td></tr>\n".replace(".", ","))
|
||||
# footer
|
||||
f.write("</table>\n")
|
||||
|
||||
Reference in New Issue
Block a user