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
# set the plot | |
plt.hist(df.life_expectancy, | |
range=(df.life_expectancy.min(), df.life_expectancy.max()+1), | |
bins=25, | |
alpha=0.5) | |
# set title, legends and labels and xticks | |
plt.xlabel("Life Expectancy") | |
plt.ylabel("Count") | |
plt.title("Histogram of Life Expectancy between 1952 and 2007 in the World") |
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
# set the plot | |
plt.hist(df.life_expectancy, | |
range=(df.life_expectancy.min(), df.life_expectancy.max()+1), | |
bins=5, | |
alpha=0.5) | |
# set title, legends and labels and xticks | |
plt.xlabel("Life Expectancy") | |
plt.ylabel("Count") | |
plt.title("Histogram of Life Expectancy between 1952 and 2007 in the World") |
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
ax = sns.kdeplot(df.life_expectancy, shade=True, color="b") | |
# set the title and x,y labels | |
plt.title("KDE Plot of Life Expectancy between 1952 and 2007 in the World") | |
plt.ylabel("Density") |
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
ax = sns.distplot(df.life_expectancy, hist=True, color="b") | |
# set title and x,y labels | |
plt.title("Distribution Plot of Life Expectancy between 1952 and 2007 in the World") | |
plt.ylabel("Density") |
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") |
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
# set the plot and title | |
sns.boxplot(x="life_expectancy", data=df, palette="Set3") | |
plt.title("Boxplot of Life Expectancy between 1952 and 2007 in the World") |
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
# set the plot with the ordered continents and title | |
sns.boxplot(x="continent", y="life_expectancy", data=df, | |
palette="Set3", | |
order=["Africa", "Asia", "Americas", "Europe", "Oceania"]) | |
plt.title("Boxplot of Life Expectancy Among Continents Between 1952 and 2007") |
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
# set plot and title | |
sns.boxenplot(x="life_expectancy", data=df,palette="Set3") | |
plt.title("Boxenplot of Life Expectancy Among Continents Between 1952 and 2007") |
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
# set plot with ordered continents and title | |
sns.boxenplot(x="continent", y="life_expectancy", data=df, | |
palette="Set3", | |
order=["Africa", "Asia", "Americas", "Europe", "Oceania"]) | |
plt.title("Boxenplot of Life Expectancy Among Continents Between 1952 and 2007") |
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
# set plot and title | |
sns.violinplot(x="life_expectancy", data=df, palette="Set3") | |
plt.title("Violinplot of Life Expectancy between 1952 and 2007 in the World") |
OlderNewer