﻿import numpy as np 
from datetime import datetime
import matplotlib.dates as mdates
from matplotlib import pyplot as plt

# 生成横纵坐标信息
dates = ['2/05','2/06','2/07','2/08','2/09','2/10','2/11',
    '2/12','2/13','2/14','2/15','2/16','2/17','2/18','2/19',
    '2/20','2/21','2/22','2/23','2/24','2/25','2/26','2/27','2/28']

xs = [datetime.strptime(d, '%m/%d').date() for d in dates]
ys = [22 ,1 ,12 ,50 ,33 ,33 ,37 ,32 ,
    1 ,42 ,14 ,1 ,1 ,28 ,26 ,35 ,
    32 ,31 ,36 ,26 ,26 ,26 ,26 ,26]

# 配置横坐标
plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%m/%d'))
plt.gca().xaxis.set_major_locator(mdates.DayLocator())

# Plot
plt.plot(xs,ys,'c')#青色
plt.plot(xs, ys,'bo')#b蓝色 m品红色点
plt.gcf().autofmt_xdate()  # 自动旋转日期标记

plt.title("exerciseRecord")#Weight
plt.xlabel("date")#X轴名称
plt.ylabel("nowdayTime")#Y轴名称

#plt.xlim(5,28)#X轴范围
plt.ylim(0,52)#Y轴范围

plt.show()