我的代码如下所示:
fig, ax = plt.subplots(figsize=(8,5))
hours = dates.HourLocator(interval = 2)
h_fmt = dates.DateFormatter('%H:%M')
ax.plot(times, y_values)
xmin, xmax = plt.xlim()
xmin_0 = math.ceil(xmin) # Rounding up to start of day
ax.set_xlim(xmin_0,)
ax.xaxis.set_major_locator(hours)
ax.xaxis.set_major_formatter(h_fmt)
ax.xaxis.set_minor_locator(mdates.MinuteLocator(interval=20))
问题是,如图所示,大x记号和小x记号似乎没有对齐。你知道吗
我试过将x轴设置为从0开始,但没有自动执行,但没有效果。你知道吗
“times”是一个datetimes数组,格式为:“2018-02-04 00:00:00”
interval
指定间隔,但不指定起点。因此,人们宁愿指定要勾选的分钟数相关问题 更多 >
编程相关推荐