Supplementary notebook:¶
Code to provide images shown in http://oscovida.github.io/2020-04-30-news-report-germanys-daily-cases-increasing.html
In [1]:
%config InlineBackend.figure_formats = ['svg']
import matplotlib.pyplot as plt
import pandas as pd
# use library from oscovida.github.io
import oscovida
In [2]:
oscovida.display_binder_link("2020-04-30-bbc-germany-increasing.ipynb")
In [3]:
cases, deaths = oscovida.get_country_data("Germany")
In [33]:
fig, ax = plt.subplots(figsize=(10, 3)) # figure size in inches
tmp = cases.diff()["2020-04-26":"2020-04-30"]
ax.bar(tmp.index, tmp.values, alpha=0.5, color="C1", label="new")
ax.set_ylabel("daily change")
ax.legend()
fig.autofmt_xdate()
fig.savefig("2020-04-30-bbc-germany-increasing1.svg")
In [39]:
fig, ax = plt.subplots(figsize=(10, 3))
oscovida.plot_daily_change(ax, cases["2020-03":"2020-05"], "C1")
fig.savefig("2020-04-30-bbc-germany-increasing2.svg")
In [13]:
table = oscovida.compose_dataframe_summary(cases, deaths)
table["2020-05-01":"2020-04-01"]
Out[13]:
In [7]:
# save as markdown for easier inclusion in webpage
table.head(n=10).to_markdown(open('2020-04-30-bbc-germany-increasing-table.md', "tw"))