本文主要是介绍ValueError: DateFormatter found a value of x=0, which is an illegal date. This usually occurs becau,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
问题:
ValueError: DateFormatter found a value of x=0, which is an illegal date. This usually occurs because you have not informed the axis that it is plotting dates, e.g., with ax.xaxis_date()
解决办法:
首先,需要将时间格式转换为字符串str(h)
其次,需要将字符串转换为可以识别的时间格式datetime.datetime.strptime(str(h), '%Y-%m-%d %H:%M:%S')
最后,画图的时候横坐标的时间标签代码设置plt.gca().xaxis.set_major_formatter(mdate.DateFormatter('%Y-%m-%d %H:%M:%S'))
这篇关于ValueError: DateFormatter found a value of x=0, which is an illegal date. This usually occurs becau的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!