Last active
October 15, 2019 13:38
-
-
Save cereniyim/0b70be9cfe44397a84d3fbf267c5c740 to your computer and use it in GitHub Desktop.
KDE plot with multiple categories
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
# create list of continents | |
continents = df['continent'].value_counts().index.tolist() | |
# set kde plot for each continent | |
for c in continents: | |
subset = df[df['continent'] == c] | |
sns.kdeplot(subset["life_expectancy"], label=c, linewidth=2) | |
# set title, x and y labels | |
plt.title("KDE Plot of Life Expectancy Among Continents Between 1952 and 2007") | |
plt.ylabel("Density") | |
plt.xlabel("Life Expectancy") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment