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 toruns_distance
andruns_hr
, respectively.Create two subplots with shared x-axis using the
plt.subplots()
method, setting the first positional parameter to 2,sharex
toTrue
, andfigsize
to(12,8)
. Assign the output tofig, (ax1, ax2)
variables.Plot distance on the first subplot, setting parameter
ax
toax1
.On the second subplot (
ax2
), add a horizontal line withaxhline()
for the average value of heart rate counted asruns_hr.mean()
. Setcolor
to'blue'
,linewidth
to1
, andlinestyle
to'-.'
.
Last updated