Skip to content

Instantly share code, notes, and snippets.

@dottyz
Created May 2, 2019 18:40
Show Gist options
  • Save dottyz/829a7f5eb553236b8f5d719350f36a57 to your computer and use it in GitHub Desktop.
Save dottyz/829a7f5eb553236b8f5d719350f36a57 to your computer and use it in GitHub Desktop.
fig, axes = plt.subplots(2, 2, figsize=(15, 15))
# Flatten the 2D axes array for ease of looping
axes = np.array(axes).flatten()
# Prepare the month description titles for each quarter
quarter_names = ['Jan. - Mar.', 'Apr. - Jun.', 'Jul. - Sept.', 'Oct. - Dec.']
for q, ax in zip(sorted(ridership['Quarter'].unique()), axes):
ax.set_title(quarter_names[(q-1)])
# Set the y-axis range for consistency across the four graphs
ax.set_ylim(0, 6000)
ax.set_ylabel('Average Daily Trips')
sns.barplot(
x='Day of Week',
y='Id',
hue='User Type',
data=ridership[ridership['Quarter']==q].groupby(['Day of Week', 'User Type'])['Id'].mean().reset_index(),
ax=ax
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment