Last active
September 17, 2019 17:15
-
-
Save shubham-singh-ss/29c8592afff8b21d721c88f111d16a98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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