Skip to content

Instantly share code, notes, and snippets.

@amandaiglesiasmoreno
Created November 22, 2021 20:46
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 amandaiglesiasmoreno/2da32c05fe0a99cc1257abb09a2e2c94 to your computer and use it in GitHub Desktop.
Save amandaiglesiasmoreno/2da32c05fe0a99cc1257abb09a2e2c94 to your computer and use it in GitHub Desktop.
# 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