Get startedGet started for free

Creating boxplots

Boxplots provide additional information about the distribution of the data that they represent. They tell us what the median of the distribution is, what the inter-quartile range is and also what the expected range of approximately 99% of the data should be. Outliers beyond this range are particularly highlighted.

In this exercise, you will use the data about medalist heights that you previously visualized as histograms, and as bar charts with error bars, and you will visualize it as boxplots.

Again, you will have the mens_rowing and mens_gymnastics DataFrames available to you, and both of these DataFrames have columns called "Height" that you will compare.

This exercise is part of the course

Introduction to Data Visualization with Matplotlib

View Course

Exercise instructions

  • Create a boxplot that contains the "Height" column for mens_rowing on the left and mens_gymnastics on the right.
  • Add x-axis tick labels: "Rowing" and "Gymnastics".
  • Add a y-axis label: "Height (cm)".

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

fig, ax = plt.subplots()

# Add a boxplot for the "Height" column in the DataFrames
____

# Add x-axis tick labels:
____

# Add a y-axis label
____

plt.show()
Edit and Run Code