Python matplotlib中x轴上的绘图日期

Python matplotlib中x轴上的绘图日期,python,matplotlib,Python,Matplotlib,在福勒。打印,我想在x轴上打印日期。我有一份日期清单: import arrow as ar date_plt = '2016-04-01' _frst_day = '2016-01-01' _last_day = '2016-12-31' [ar.get(date_plt) + timedelta(days=x) for x in range((ar.get(_last_day) - ar.get(_frst_day)).days + 1)] 如何在x轴上绘制日期,同时仍能在绘图上绘制线和点

在福勒。打印,我想在x轴上打印日期。我有一份日期清单:

import arrow as ar
date_plt = '2016-04-01'
_frst_day = '2016-01-01'
_last_day = '2016-12-31'
[ar.get(date_plt) + timedelta(days=x) for x in range((ar.get(_last_day) - ar.get(_frst_day)).days + 1)]
如何在x轴上绘制日期,同时仍能在绘图上绘制线和点,如图所示


我想你需要用一些代码来生成一个假的情节:

labels=[ar.get(date_plt) + timedelta(days=x) for x in range((ar.get(_last_day)-ar.get(_frst_day)).days + 1)]
x=np.arange(366)
y=x*10
plt.plot([l.datetime for l in labels],y) #convert arrow in datetime
请注意,通过这种方式打印datetime对象,并由matplotlib自动处理,例如在缩放和间距调整中,而不是在x、y和替换记号上打印。 要打印或注释数据,可以直接寻址到日期时间x轴,例如第150天:

plt.plot(labels[150].datetime,y[150],'o')
plt.annotate('day 150',(labels[150].datetime,y[150]))

什么是日期?谢谢@eyllanesc,更新的问题