Visualizing with seaborn
Box Plots
Another way of showing both central tendency and dispersion is the
boxplot. In Seaborn, we can create boxplots by using the kind='box'
argument.
# create boxplot sns.boxplot(x = "State", y = "Rates.Violent.All", data = dfi) plt.show()
# create horizontal boxplot sns.boxplot(y = "State", x = "Rates.Violent.All", data=dfi) plt.show()
# create masks smalli_mask = dfi.loc[:, 'State'].isin(['Idaho', 'Iowa']) recent_mask = dfi.loc[:, 'Decade'] > 1990 # create boxplots sns.boxplot(x = "State", y = "Rates.Violent.All", hue = 'Decade', data = dfi.loc[smalli_mask & recent_mask]) plt.show()