Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# create a figure
fig = plt.figure(figsize=(10, 6))
ax = fig.add_subplot(111)
# proportion of observation of each class
prop_response = df_telco['Churn'].value_counts(normalize=True)
# create a bar plot showing the percentage of churn
prop_response.plot(kind='bar',
ax=ax,
color=['springgreen','salmon'])
# set title and labels
ax.set_title('Proportion of observations of the response variable',
fontsize=18, loc='left')
ax.set_xlabel('churn',
fontsize=14)
ax.set_ylabel('proportion of observations',
fontsize=14)
ax.tick_params(rotation='auto')
# eliminate the frame from the plot
spine_names = ('top', 'right', 'bottom', 'left')
for spine_name in spine_names:
ax.spines[spine_name].set_visible(False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment