Skip to content

Instantly share code, notes, and snippets.

@matteo-peltarion
Last active March 25, 2020 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matteo-peltarion/354d8f3268b778be6c90d70b15daf2e6 to your computer and use it in GitHub Desktop.
Save matteo-peltarion/354d8f3268b778be6c90d70b15daf2e6 to your computer and use it in GitHub Desktop.
COVID-19 analysis code 04 - plot cases
# Estimate a reasonable value for Y tick given the maximum number of cases
Y_GRID_TICK = 10**int(np.log10(country_df['Confirmed'].max()))/2
ax = plt.gca()
sns.set_style("whitegrid", {'grid.linestyle': ':'})
ax.xaxis.set_major_locator(ticker.MultipleLocator(4))
# Plot
country_df.plot(x='Date', y=["Confirmed", "Deaths", "Recovered"], figsize=(18,9), ax=ax, marker='o')
country_df.plot(x='Date', y=["Increase"], secondary_y=True, figsize=(18,9), ax=ax, marker='o')
# Improve display of
ax.xaxis.set_major_formatter(mdates.DateFormatter('%d-%m-%Y'))
# Set y label and plot title
ax.set_ylabel("# of confirmed cases");
ax.set_title("Daily numbers of confirmed cases, deaths and hospitalized people. Daily increase refers to numbers on the right y axis.");
# Uncomment if you want to save the image
# plt.savefig("daily_data.png");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment