因此,我使用修改过的教程,使用matplotlib绘制了大约5k的时间日期。我想删除所有年份的year-01
和year-07
之间的范围,以使数据更有趣。
这是我的代码:
import matplotlib.pyplot as plt
def plotTimes(data):
x = data["x"]
y = data["y"]
fig = plt.figure()
ax = fig.add_subplot(111)
ax.grid()
plt.plot(x,y)
plt.xlabel('Date')
plt.ylabel('5k Time')
plt.title(data['name'])
plt.show()
所有代码: https://pastebin.com/raw/MQVa5QLZ
这是数据:
{'x': [datetime.datetime(2015, 8, 28, 0, 0), datetime.datetime(2015,
9, 3, 0, 0), datetime.datetime(2015, 9, 10, 0, 0), datetime.datetime(2015, 9, 12, 0, 0), datetime.datetime(2015, 9, 17, 0, 0), datetime.datetime(2015, 9, 26, 0, 0), datetime.datetime(2015, 9, 29, 0,
0), datetime.datetime(2015, 10, 3, 0, 0), datetime.datetime(2015, 10, 16,
0, 0), datetime.datetime(2015, 10, 22, 0, 0), datetime.datetime(2015, 10,
23, 0, 0), datetime.datetime(2015, 10, 27, 0, 0), datetime.datetime(2015,
10, 30, 0, 0), datetime.datetime(2015, 11, 4, 0, 0),
datetime.datetime(2016, 8, 26, 0, 0), datetime.datetime(2016, 9, 1, 0, 0),
datetime.datetime(2016, 9, 10, 0, 0), datetime.datetime(2016, 9, 13, 0,
0), datetime.datetime(2016, 9, 15, 0, 0), datetime.datetime(2016, 9, 24, 0, 0), datetime.datetime(2016, 9, 27, 0, 0), datetime.datetime(2016, 10,
14, 0, 0), datetime.datetime(2016, 10, 20, 0, 0), datetime.datetime(2016,
10, 21, 0, 0), datetime.datetime(2016, 10, 25, 0, 0), datetime.datetime(2016, 10, 29, 0, 0), datetime.datetime(2016, 11, 2, 0,
0), datetime.datetime(2017, 8, 25, 0, 0), datetime.datetime(2017, 9, 9,
0, 0), datetime.datetime(2017, 9, 12, 0, 0), datetime.datetime(2017, 9,
14, 0, 0), datetime.datetime(2017, 9, 23, 0, 0), datetime.datetime(2017,
9, 27, 0, 0), datetime.datetime(2017, 10, 7, 0, 0),
datetime.datetime(2017, 10, 28, 0, 0), datetime.datetime(2017, 11, 1, 0,
0)], 'y': [datetime.datetime(1900, 1, 1, 0, 20, 4, 100000),
datetime.datetime(1900, 1, 1, 0, 19, 59, 700000), datetime.datetime(1900, 1, 1, 0, 18, 48, 100000), datetime.datetime(1900, 1, 1, 0, 18, 26),
datetime.datetime(1900, 1, 1, 0, 18, 49, 600000), datetime.datetime(1900,
1, 1, 0, 17, 57), datetime.datetime(1900, 1, 1, 0, 18, 28, 200000),
datetime.datetime(1900, 1, 1, 0, 17, 34, 800000), datetime.datetime(1900,
1, 1, 0, 17, 46), datetime.datetime(1900, 1, 1, 0, 17, 57, 700000),
datetime.datetime(1900, 1, 1, 0, 17, 43, 200000), datetime.datetime(1900,
1, 1, 0, 17, 54, 700000), datetime.datetime(1900, 1, 1, 0, 17, 40,
700000), datetime.datetime(1900, 1, 1, 0, 17, 55, 600000),
datetime.datetime(1900, 1, 1, 0, 18, 29, 200000), datetime.datetime(1900,
1, 1, 0, 17, 43, 300000), datetime.datetime(1900, 1, 1, 0, 17, 51),
datetime.datetime(1900, 1, 1, 0, 18, 12, 500000), datetime.datetime(1900,
1, 1, 0, 17, 30, 100000), datetime.datetime(1900, 1, 1, 0, 17, 9,
800000), datetime.datetime(1900, 1, 1, 0, 17, 58), datetime.datetime(1900,
1, 1, 0, 17, 16, 800000), datetime.datetime(1900, 1, 1, 0, 17, 43,
600000), datetime.datetime(1900, 1, 1, 0, 17, 12, 400000),
datetime.datetime(1900, 1, 1, 0, 17, 31, 600000), datetime.datetime(1900,
1, 1, 0, 17, 36, 700000), datetime.datetime(1900, 1, 1, 0, 17, 13,
900000), datetime.datetime(1900, 1, 1, 0, 17, 17,
700000), datetime.datetime(1900, 1, 1, 0, 16, 42), datetime.datetime(1900, 1, 1, 0,
16, 56, 200000), datetime.datetime(1900, 1, 1, 0, 17, 11, 700000),
datetime.datetime(1900, 1, 1, 0, 16, 51, 900000),
datetime.datetime(1900, 1, 1, 0, 17, 15, 200000), datetime.datetime(1900, 1, 1, 0, 17, 9,
700000),
datetime.datetime(1900, 1, 1, 0, 16, 55, 600000),
datetime.datetime(1900, 1, 1, 0, 17, 2, 400000)], 'name': 'Jack Santinga'}