December 2018
Beginner to intermediate
682 pages
18h 1m
English
Seaborn makes the task of visualizing the distribution of a dataset much easier. Starting with the population data as discussed before, let's see how it distributes among different countries in 2017 by plotting a bar plot:
import seaborn as snsimport matplotlib.pyplot as plt# Extract USA population data in 2017current_population = population_df[(population_df.Location == 'United States of America') & (population_df.Time == 2017) & (population_df.Sex != 'Both')]# Population Bar chart sns.barplot(x="AgeGrp",y="Value", hue="Sex", data = current_population)# Use Matplotlib functions to label axes rotate tick labelsax = plt.gca()ax.set(xlabel="Age Group", ylabel="Population (thousands)")ax.set_xticklabels(ax.xaxis.get_majorticklabels(), ...