Measuring the distance
In order to understand the elevation data chart, we need reference points along the x axis to help us determine the elevation along the route. We will calculate the mile splits along the route and place these at the appropriate location on the x axis of our charts:
# Locate the mile markers for i in range(1, int(round(total))): mile = 0 while mile < i: j += 1 mile += distances[j] measurements.append((int(mile), j)) j =- 1 # Set up labels for the mile points positions = [] miles = [] for m, i in measurements: pos = ((i*1.0)/len(elvs)) * 100 positions.append(pos) miles.append(m) # Position the mile marker labels along the x axis miles_label = chart.set_axis_labels(Axis.BOTTOM, miles) chart.set_axis_positions(miles_label, positions) # Label the x axis as "Miles" miles_text = chart.set_axis_labels(Axis.BOTTOM, ["MILES", ]) chart.set_axis_positions(miles_text, [50, ]) # Save the chart chart.download...