in python/prophet/plot.py [0:0]
def plot_weekly(m, ax=None, uncertainty=True, weekly_start=0, figsize=(10, 6), name='weekly'):
"""Plot the weekly component of the forecast.
Parameters
----------
m: Prophet model.
ax: Optional matplotlib Axes to plot on. One will be created if this
is not provided.
uncertainty: Optional boolean to plot uncertainty intervals, which will
only be done if m.uncertainty_samples > 0.
weekly_start: Optional int specifying the start day of the weekly
seasonality plot. 0 (default) starts the week on Sunday. 1 shifts
by 1 day to Monday, and so on.
figsize: Optional tuple width, height in inches.
name: Name of seasonality component if changed from default 'weekly'.
Returns
-------
a list of matplotlib artists
"""
artists = []
if not ax:
fig = plt.figure(facecolor='w', figsize=figsize)
ax = fig.add_subplot(111)
# Compute weekly seasonality for a Sun-Sat sequence of dates.
days = (pd.date_range(start='2017-01-01', periods=7) +
pd.Timedelta(days=weekly_start))
df_w = seasonality_plot_df(m, days)
seas = m.predict_seasonal_components(df_w)
days = days.day_name()
artists += ax.plot(range(len(days)), seas[name], ls='-',
c='#0072B2')
if uncertainty and m.uncertainty_samples:
artists += [ax.fill_between(range(len(days)),
seas[name + '_lower'], seas[name + '_upper'],
color='#0072B2', alpha=0.2)]
ax.grid(True, which='major', c='gray', ls='-', lw=1, alpha=0.2)
ax.set_xticks(range(len(days)))
ax.set_xticklabels(days)
ax.set_xlabel('Day of week')
ax.set_ylabel(name)
if m.seasonalities[name]['mode'] == 'multiplicative':
ax = set_y_as_percent(ax)
return artists