Skip to content

Instantly share code, notes, and snippets.

@themagiulio
Created March 19, 2020 10:40
Show Gist options
  • Save themagiulio/fdc1f2a70faeeca0163c9f37bd9d84fa to your computer and use it in GitHub Desktop.
Save themagiulio/fdc1f2a70faeeca0163c9f37bd9d84fa to your computer and use it in GitHub Desktop.
COVID-19 Real-time Italy plot of Deaths and Cases
from matplotlib.dates import DateFormatter
import matplotlib.pyplot as plt
import pandas as pd
import os
source = 'https://www.ecdc.europa.eu/sites/default/files/documents/COVID-19-geographic-disbtribution-worldwide-2020-03-18.xls'
index = 'DateRep'
df = pd.read_excel(source, index_col=index)
df_it = df.loc[df['Countries and territories'] == 'Italy'][::-1]
X = df_it.index
y = df_it['Deaths']
z = df_it['Cases']
fig, ax = plt.subplots(figsize=(12, 8))
ax.plot(X, y, label='Deaths', color='black')
ax.plot(X, z, label='Cases', color='orange')
date_form = DateFormatter("%Y %b")
ax.xaxis.set_major_formatter(date_form)
ax.legend()
plt.savefig('plot.png')
print('=============================')
print('The plot has been generated.')
print('=============================')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment