Я составил график временных рядов потоков углерода за 16 лет на конкретном участке.Я бы хотел, чтобы на оси х были годы (1992-2007) вместо номера года (1-16).Когда для оси x задано минимальное значение 1992 года и максимальное значение 2007 года, график не отображается на графике, но когда я не устанавливаю минимальный / максимальный годы, он появляется.Я не уверен, что я делаю неправильно.Я построил еще одну серию времени за один год и смог пометить ось X с месяцами, используя MonthLocator, но мне не повезло с YearLocator.Вот код, который я написал:
fig=pyplot.figure()
ax=fig.gca()
ax.plot_date(days,nee,'r-',label='model daily nee')
ax.plot_date(days,nee_obs,'b-',label='obs daily nee')
# locate the ticks
ax.xaxis.set_major_locator(YearLocator())
# format the ticks
ax.xaxis.set_major_formatter(DateFormatter('%Y'))
# set years 1992-2007
datemin = datetime.date(1992, 1, 1)
datemax = datetime.date(2007, 12, 31)
ax.set_xlim(datemin, datemax)
labels=ax.get_xticklabels()
setp(labels,'rotation',45,fontsize=10)
legend(loc="upper right", bbox_to_anchor=[0.98, 0.98],
ncol=1, shadow=True)
pyplot.ylabel('NEE($gC m^{-2} day^{-1}$)')
pyplot.title('Net Ecosystem Exchange')
pyplot.savefig('nee_obs_model_HF_daily.pdf')
# rotates and right aligns the x labels, and moves the bottom of the
# axes up to make room for them
#fig.autofmt_xdate()
pyplot.show()
pyplot.close()