Skip to content

Instantly share code, notes, and snippets.

Created February 3, 2018 08:55
What would you like to do?
import numpy as np
import plotly
import math
from plotly.graph_objs import Layout, Bar
activity = GC.activity()
metrics = GC.activityMetrics()
date = metrics.get("date")
zone = GC.athleteZones(date=date, sport="bike")
lows = zone.get("zoneslow")
colors = zone.get("zonescolor")
duration = activity.get("seconds")[-1]
p = list(activity.get("power"))
n = 50
step = math.ceil(len(p)/math.ceil(len(p)/n))
chunks = [p[x:x+step] for x in range(0, len(p), step)]
p2 = list(map(lambda x: sum(x) / len(x), chunks))
ff = np.searchsorted(lows[0], p2, side='right')
cc = list(map(lambda x: colors[0][x-1], ff))
time = list(range(len(p2)))
f = plotly.offline.plot({
"data": [Bar(x=time, y=p2, marker=dict(
"layout": Layout(title="Power in zones over time")
}, auto_open = False)
# f[7:] used as workaround for defect Windows uri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment