python 用于下载和绘制MapMyFitness数据的代码
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 用于下载和绘制MapMyFitness数据的代码相关的知识,希望对你有一定的参考价值。
from mapmyfitness import MapMyFitness
import matplotlib.pyplot as plt
import matplotlib
import numpy as np
def get_workouts():
# Log in
mmf = MapMyFitness(api_key='6du8934wfvrdqnbtzd9h9kxbstdqrn2x', \
access_token='237eee8b8f8bc541841d902ea9a533fa07b748b4')
# get all workouts
workouts = mmf.workout.search(user=48155002,per_page=50000)
workout_list = workouts.page(1)
paces = []
distances = []
dates = []
for i,workout in enumerate(workout_list):
print "processing workout " + str(i+1) + " of " + str(len(workout_list))
if 'run' in workout.activity_type.name.lower():
distances.append(workout.distance_total/1609.344) # convert meters to miles
paces.append(26.8224/workout.speed_avg) # convert m/s to minutes per mile
dates.append(workout.start_datetime)
return distances, paces, dates, workout_list
if __name__ == '__main__':
months = matplotlib.dates.MonthLocator(bymonthday=15) # every month
monthsFmt = matplotlib.dates.DateFormatter('%b')
distances, paces, dates, workouts = get_workouts()
d = np.array([matplotlib.dates.date2num(dd) for dd in dates])
fig, ax = plt.subplots()
ax.plot_date(d,paces,'ok')
ax.xaxis.set_major_locator(months)
ax.xaxis.set_major_formatter(monthsFmt)
plt.ylabel('Pace (minutes per mile)')
fig, ax = plt.subplots()
plt.plot_date(d,distances,'ok')
ax.xaxis.set_major_locator(months)
ax.xaxis.set_major_formatter(monthsFmt)
plt.ylabel('Distance (miles)')
以上是关于python 用于下载和绘制MapMyFitness数据的代码的主要内容,如果未能解决你的问题,请参考以下文章
TikZ 绘制 MapReduce 示意图
比较用于绘制网络拓扑的开源 Java 图形绘制框架(JUNG 和 Prefuse)
用于绘制图形和滚动的面板
Doxygen生成美丽注释文档:初体验
如何使用 mxGraph 绘制可定制化的流程图
opencv学习笔记基本图像的绘制——直线椭圆矩形圆和多边形