Skip to content

Instantly share code, notes, and snippets.

@shubham-singh-ss
Last active September 17, 2019 17:15
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 shubham-singh-ss/29c8592afff8b21d721c88f111d16a98 to your computer and use it in GitHub Desktop.
Save shubham-singh-ss/29c8592afff8b21d721c88f111d16a98 to your computer and use it in GitHub Desktop.
# Initialize the FacetGrid object
g = sns.FacetGrid(df2, row="gender", hue="gender", aspect=5, height=3)
# # Draw the densities in a few steps
g.map(sns.kdeplot, "age", shade=True, alpha=1, lw=3.5, bw=.2)
g.map(sns.kdeplot, "age", color="w", lw=2, bw=.2)
g.map(plt.axhline, y=0, lw=2)
# # Define and use a simple function to label the plot in axes coordinates
def label(x, color, label):
ax = plt.gca()
ax.text(0, .2, label, color=color, ha="left", va="center", transform=ax.transAxes)
g.map(label, "age")
# Set the subplots to overlap
g.fig.subplots_adjust(hspace=-.25)
# # Remove axes details that don't play well with overlap
g.set_titles("")
g.set(yticks=[])
g.despine(bottom=True, left=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment