Skip to content

Instantly share code, notes, and snippets.

@cereniyim
Last active October 15, 2019 13:38
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 cereniyim/0b70be9cfe44397a84d3fbf267c5c740 to your computer and use it in GitHub Desktop.
Save cereniyim/0b70be9cfe44397a84d3fbf267c5c740 to your computer and use it in GitHub Desktop.
KDE plot with multiple categories
# 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