Task 6

Visualization with averages

Let's plot the long term averages of my distance run and my heart rate with their raw data to visually compare the averages to each training session. Again, we'll use the data from 2015 through 2018.

In this task, we will use matplotlib functionality for plot creation and customization.

Prepare data and create a plot.

  • Select information for distance and then for heart rate from runs_subset_2015_2018 and assign to runs_distance and runs_hr, respectively.

  • Create two subplots with shared x-axis using the plt.subplots() method, setting the first positional parameter to 2, sharex to True, and figsize to (12,8). Assign the output to fig, (ax1, ax2) variables.

  • Plot distance on the first subplot, setting parameter ax to ax1.

  • On the second subplot (ax2), add a horizontal line with axhline() for the average value of heart rate counted as runs_hr.mean(). Set color to 'blue', linewidth to 1, and linestyle to '-.'.

Last updated