【发布时间】:2018-08-01 07:49:49
【问题描述】:
我有一个图表,其中 X 为日期,Y 为一些读数。 X 轴有一个以一天为增量的日期间隔。我想要的是在 x 轴上显示两天之间的小时数(只是为了在图中的黄色区域设置小时数)。 代码的思路是:
Date=[];Readings=[] # will be filled from another function
dateconv=np.vectorize(datetime.fromtimestamp)
Date_F=dateconv(Date)
ax1 = plt.subplot2grid((1,1), (0,0))
ax1.plot_date(Date_F,Readings,'-')
for label in ax1.xaxis.get_ticklabels():
label.set_rotation(45)
ax1.grid(True)
plt.xlabel('Date')
plt.ylabel('Readings')
ax1.set_yticks(range(0,800,50))
plt.legend()
plt.show()
【问题讨论】:
标签: python python-3.x matplotlib graph