1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Data Visualization with Matplotlib

Exercise

"Step" histogram

Histograms allow us to see the distributions of the data in different groups in our data. In this exercise, you will select groups from the Summer 2016 Olympic Games medalist dataset to compare the height of medalist athletes in two different sports.

The data is stored in a pandas DataFrame object called summer_2016_medals that has a column "Height". In addition, you are provided a pandas GroupBy object that has been grouped by the sport.

In this exercise, you will visualize and label the histograms of two sports: "Gymnastics" and "Rowing" and see the marked difference between medalists in these two sports.

Instructions

100 XP
  • Use the hist method to display a histogram of the "Weight" column from the mens_rowing DataFrame, label this as "Rowing".
  • Use hist to display a histogram of the "Weight" column from the mens_gymnastics DataFrame, and label this as "Gymnastics".
  • For both histograms, use the histtype argument to visualize the data using the 'step' type and set the number of bins to use to 5.
  • Add a legend to the figure, before it is displayed.