Lab 7, Part 3: Ironman data visualization

In this part of lab, we are working with small tuples of data culled from the Ironman Kona 2016 (Age Group 18-24 year old) results.

Open lab07/ironman-viz.py— at the top of the file, we have provided you with the tuples of the 5 fastest swim, bike, and run legs of the triathlon.

fastestSwim = (('BEL',0.53),('FIN',0.53),('NOR',0.57),('BRA',0.73),('AUS',0.79))
fastestBike = (('AUS',4.72),('RUS',5.0),('FIN',5.03),('NOR',5.05),('BEL',5.06))
fastestRun = (('NOR',3.17),('RUS',3.21),('MEX',3.21),('GBR',3.39),('AUS',3.41))
fastestOverall = (('NOR',9.26),('RUS',9.32),('AUS',9.35),('FIN',9.46),('BRA',10.22))

This data is provided so you can focus on the visualization (plotting) process.

Reference

The following resources may be helpful for your tasks in this part of the lab:

Task 0. Set up for plotting

Running your plotting code in Canopy places your plots in the inline Python window.

To have your plots pop up in a separate window, do this:

  1. Canopy > Preferences...
  2. Click on the Python tab
  3. In the PyLab backend drop-down menu, select Interactive (wx)

Task 1. makeBarChartVersion1 - Simple bar chart with race data

Write a function called makeBarChartVersion1 that takes one of the provided tuples and creates the corresponding plot.

makeBarChartVersion1(fastestSwim)
makeBarChartVersion1(fastestBike)

Task 2. makeBarChartVersion2 - Better bar charts

There are several ways in which we can improve the bar graph shown in the task above.

Write a new version of your function (call it makeBarChartVersion2) by adding these improvements (add them in one at a time):

makeBarChartVersion2(fastestSwim, 'Top 5 Ironman Swim Times, Ages 18-24')
makeBarChartVersion2(fastestBike, 'Top 5 Ironman Bike Times, Ages 18-24')

Task 3. makePieChart - Pie charts

Write a function called makePieChart that takes one of the dictionaries from the original list of dictionaries (kona.py) and creates a pie chart showing how time is spent during the ironman race for a particular athlete.

Note: these Pie Chart reference notes might be helpful.

makePieChart(kona[2])
makePieChart(kona[30])

Table of Contents