Skip to content

Instantly share code, notes, and snippets.

@alinazhanguwo
Last active October 15, 2020 18:39
Show Gist options
  • Save alinazhanguwo/c0696a2044e9cc59e7f4a464badf9535 to your computer and use it in GitHub Desktop.
Save alinazhanguwo/c0696a2044e9cc59e7f4a464badf9535 to your computer and use it in GitHub Desktop.
Number of deaths and confirmed cases in top 10 states of America (2020-09-13)
fig1, (ax1, ax2) = plt.subplots(1,2, figsize=(12,8), sharey=False)
fig1.tight_layout()
fig1.subplots_adjust(top=0.86)
sns.set_color_codes("pastel")
sns.barplot(x="Deaths", y="Province/State", data=bar_plot_df, label="num of Deaths", color="b", ax=ax1)
ax1.legend(ncol=2, loc="lower left", frameon=True)
ax1.set(xlim=(0, 33323), ylabel="", xlabel="Num of Deaths by states")
sns.despine(left=True, bottom=True,ax=ax1)
for tick in ax1.yaxis.get_major_ticks():
tick.label.set_fontsize(14)
for tick in ax1.xaxis.get_major_ticks():
tick.label.set_fontsize(12)
sns.set_color_codes("pastel")
sns.barplot(x="Confirmed", y="Province/State", data=bar_plot_df, label="num of Confirmed Cases", color="b", ax=ax2)
ax2.legend(ncol=2, loc="lower right", frameon=True)
ax2.set(xlim=(0, 765728), ylabel="", xlabel="Num of Confirmed Cases by states") #The xlim value comes from the maximum value in the dataset.
ax2.set_yticklabels([''])
sns.despine(left=True, bottom=True, ax=ax2)
for tick in ax2.xaxis.get_major_ticks():
tick.label.set_fontsize(12)
plt.suptitle('Number of deaths and confirmed cases in top 10 states of America (2020-09-13)', fontsize=24, fontweight='bold')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment