【发布时间】:2020-07-11 04:29:06
【问题描述】:
我对绘制时间序列数据有疑问。我想每 10 年显示一次 x 轴,但我只能每年显示一次。任何人都可以提供解决方案吗??
fig,ax = plt.subplots(figsize=(11,4))
ax.plot(t, data, '0.1', label ='Data')
ax.plot(t, df_filt, 'C1', label='Lowpass Filter, cutoff=50 days')
ax.set_ylabel('Length of Day')
ax.set_xlabel('Time')
ax.legend()
ax.xaxis.set_major_locator(mdates.YearLocator())
ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y'))
ax.grid(True)
【问题讨论】:
-
set_major_locator(mdates.YearLocator(10))docs
标签: matplotlib time-series axis