没有在绘图上获得时间,但日期绘图正确,请检查列表dateIndex
是否始终显示。
输出图如下所示:
def graphData(dateIndex,irValue,mar):
dateIndex.pop() #take out the empty string
irValue.pop() #equalising the size
avgData = movingaverage(irValue,mar)
spLen = len(dateIndex[mar-1:])
fig = plt.figure()
ax1 = plt.subplot(1,1,1)
date = mdates.strpdate2num('%Y-%m-%d %H:%M:%S')
datenum = [date(i) for i in dateIndex] # date function here.
ax1.plot(datenum[-spLen:], avgData[-spLen:])
ax1.grid(True)
ax1.xaxis.set_major_locator(mticker.MaxNLocator(20))
ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d \n %H:%M:%S'))
for label in ax1.xaxis.get_ticklabels():
label.set_rotation(45)
plt.show()
目前没有回答
相关问题 更多 >
编程相关推荐