我有一个带有两列的pandas系列,Index(时间戳)和浮点数
我尝试使用Matplotlib绘图如下
s2.plot()
给出了以下情节
现在我想格式化x轴,只显示'%Y-%m-%d'格式的时间戳 所以我试试
fig, ax = plt.subplots()
xdfmt = dates.DateFormatter('%Y-%m-%d')
ax.xaxis.set_major_formatter(xdfmt)
ax.xaxis_date()
s2.plot()
失败如下
dt = datetime.datetime.fromordinal(ix).replace(tzinfo = UTC)
ValueError:序数必须为> = 1
如何格式化x轴以显示清晰的x轴标签?