# My First Half Marathon!

I recently ran my first half marathon! Iâ€™m also signed up for a full marathon in October. ðŸ˜¬

Anyway, to celebrate the occasion and because I have now have a reason to think about how fast I might run a particular distance. I had a look at my historical run data. Thereâ€™s a great website called statshunter that you can authorise to Strava and from which you can download a little csv of all your runs. The first logical thing I could think to do is to see how fast I tend to run different distances.

A friend lent me a huge running book which Iâ€™m going to dig through more but I suspect one of the conclusions will be a bit obvious: I could run those shorter distances a lot faster.

That same friend also lent me a heart rate watch which Iâ€™ve been playing with. So the next thing I want to learn about is what type of heart rates you should target when you train for a particular event.

Code:

1from matplotlib import pyplot as plt 2import numpy as np 3from datetime import datetime 4import pandas as pd 5 6runs = pd.read_csv("runs.csv", parse_dates = ["Date"]) # Get this from statshunter.com 7 8f, (ax2, ax) = plt.subplots(nrows=2, figsize = (5,5), sharex = True, 9 gridspec_kw = dict(height_ratios = (1,2)))1011ax.set(ylabel = "Moving Time (mins)", xlabel = "Distance (km)") 12 13x = runs["Distance (m)"].values/1e3 14y = runs["Moving time"].values/60 15 16dists = np.linspace(1, 25, 2) 17for i in [5,6,7]: 18 mins_per_km = i * dists 19 ax.plot(dists, mins_per_km, color = "black", linestyle = "dotted", label = f"{i} min/km")20ax.text(25.5, 25*i, f"{i} min/km", va = "center") 21 22ax.annotate("Half Marathon!", (x[0], y[0]-1), (20, 50), arrowprops = dict(arrowstyle = "->")) 23 24ax.scatter(x, y, s=20, alpha = 0.6*fade_out_by_date(runs["Date"])) 25for a in [ax, ax2]: a.spines[['right', 'top']].set_visible(False) 26 27ax2.hist(x, bins = 30, alpha = 0.5) 28ax2.set(yticks=[], ylabel = "Frequency Density") 2930f.savefig("time_vs_distance_plus_hist.svg", transparent=True)