Learn
Learn Seaborn: Distributions
Box Plots, Part II

One advantage of the box plot over the KDE plot is that in Seaborn, it is easy to plot multiples and compare distributions.

Let’s look again at our three datasets, and how they look plotted as box plots:

sns.boxplot(data=df, x='label', y='value') plt.show()

alt

The box plot does a good job of showing certain differences, the different between Dataset 1 and Dataset 2; however, it does not show that Dataset 3 is bimodal.

To plot a box plot in Seaborn, we use the method sns.boxplot().

A box plot takes the following arguments:

  • data - the dataset we’re plotting, like a DataFrame, list, or an array
  • x - a one-dimensional set of values, like a Series, list, or array
  • y - a second set of one-dimensional data

If you use a Pandas Series for the x and y values, the Series will also generate the axis labels. For example, if you use the value Series as your y value data, Seaborn will automatically apply that name as the y-axis label.

Instructions

1.

Use sns.boxplot() to plot the four datasets as box plots.

2.

Use plt.show() to display the box plots. What else can we learn about these datasets?

Folder Icon

Sign up to start coding

Already have an account?