def plotYearly(dictframe, ax, uncertainty, color='#0072B2'):
if ax is None:
figY = plt.figure(facecolor='w', figsize=(10, 6))
ax = figY.add_subplot(111)
else:
figY = ax.get_figure()
##
# Find the max index for an entry of each month
##
months = dictframe.ds.dt.month
ind = []
for month in range(1,13):
ind.append(max(months[months == month].index.tolist()))
##
# Plot from the minimum of those maximums on (this will almost certainly result in only 1 year plotted)
##
ax.plot(dictframe['ds'][min(ind):], dictframe['yearly'][min(ind):], ls='-', c=color)
if uncertainty:
ax.fill_between(dictframe['ds'].values[min(ind):], dictframe['yearly_lower'][min(ind):], dictframe['yearly_upper'][min(ind):], color=color, alpha=0.2)
ax.grid(True, which='major', c='gray', ls='-', lw=1, alpha=0.2)
months = MonthLocator(range(1, 13), bymonthday=1, interval=2)
ax.xaxis.set_major_formatter(FuncFormatter(
lambda x, pos=None: '{dt:%B} {dt.day}'.format(dt=num2date(x))))
ax.xaxis.set_major_locator(months)
ax.set_xlabel('Day of year')
ax.set_ylabel('yearly')
figY.tight_layout()
return figY
评论列表
文章目录