Code to provide images shown in http://oscovida.github.io/2020-04-30-news-report-germanys-daily-cases-increasing.html
%config InlineBackend.figure_formats = ['svg']
import matplotlib.pyplot as plt
import pandas as pd
# use library from oscovida.github.io
import coronavirus
import ipyparams
coronavirus.display_binder_link(ipyparams.notebook_name)
cases, deaths, country_label = coronavirus.get_country_data("Germany")
fig, ax = plt.subplots(figsize=(10, 3)) # figure size in inches
coronavirus.plot_daily_change(ax, cases, "C1")
min_, max_ = ax.get_xlim() # presumably measured in days
date_2020_04_30 = 737545 # retrieved with ax.get_xlim and
# saved for convenience.
# there must be a better way of converting to and
# frome day-month-year.
doi = date_2020_04_30 # Date Of Interest
ax.set_xlim([doi-4, doi+2]) # units are days
ax.set_ylim([0, 2000])
fig.savefig("2020-04-30-bbc-germany-increasing1.svg")
fig, ax = plt.subplots(figsize=(10, 3))
coronavirus.plot_daily_change(ax, cases, "C1")
ax.set_xlim([doi-80, doi+2])
fig.savefig("2020-04-30-bbc-germany-increasing2.svg")
table = coronavirus.compose_dataframe_summary(cases, deaths)
table.head(n=10)
total cases | daily new cases | total deaths | daily new deaths | |
---|---|---|---|---|
2020-05-24 | 180328 | 342 | 8283 | 22 |
2020-05-23 | 179986 | 276 | 8261 | 33 |
2020-05-22 | 179710 | 689 | 8228 | 25 |
2020-05-21 | 179021 | 548 | 8203 | 59 |
2020-05-20 | 178473 | 695 | 8144 | 63 |
2020-05-19 | 177778 | 1227 | 8081 | 78 |
2020-05-18 | 176551 | 182 | 8003 | 41 |
2020-05-17 | 176369 | 617 | 7962 | 24 |
2020-05-16 | 175752 | 519 | 7938 | 41 |
2020-05-15 | 175233 | 755 | 7897 | 13 |
# save as markdown for easier inclusion in webpage
table.head(n=10).to_markdown(open('2020-04-30-bbc-germany-increasing-table.md', "tw"))