MCPcopy
hub / github.com/facebook/prophet / plot_weekly

Function plot_weekly

python/prophet/plot.py:276–319  ·  view source on GitHub ↗

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.unce

(m, ax=None, uncertainty=True, weekly_start=0, figsize=(10, 6), name='weekly')

Source from the content-addressed store, hash-verified

274
275
276def plot_weekly(m, ax=None, uncertainty=True, weekly_start=0, figsize=(10, 6), name='weekly'):
277 """Plot the weekly component of the forecast.
278
279 Parameters
280 ----------
281 m: Prophet model.
282 ax: Optional matplotlib Axes to plot on. One will be created if this
283 is not provided.
284 uncertainty: Optional boolean to plot uncertainty intervals, which will
285 only be done if m.uncertainty_samples > 0.
286 weekly_start: Optional int specifying the start day of the weekly
287 seasonality plot. 0 (default) starts the week on Sunday. 1 shifts
288 by 1 day to Monday, and so on.
289 figsize: Optional tuple width, height in inches.
290 name: Name of seasonality component if changed from default 'weekly'.
291
292 Returns
293 -------
294 a list of matplotlib artists
295 """
296 artists = []
297 if not ax:
298 fig = plt.figure(facecolor='w', figsize=figsize)
299 ax = fig.add_subplot(111)
300 # Compute weekly seasonality for a Sun-Sat sequence of dates.
301 days = (pd.date_range(start='2017-01-01', periods=7) +
302 pd.Timedelta(days=weekly_start))
303 df_w = seasonality_plot_df(m, days)
304 seas = m.predict_seasonal_components(df_w)
305 days = days.day_name()
306 artists += ax.plot(range(len(days)), seas[name], ls='-',
307 c='#0072B2')
308 if uncertainty and m.uncertainty_samples:
309 artists += [ax.fill_between(range(len(days)),
310 seas[name + '_lower'], seas[name + '_upper'],
311 color='#0072B2', alpha=0.2)]
312 ax.grid(True, which='major', c='gray', ls='-', lw=1, alpha=0.2)
313 ax.set_xticks(range(len(days)))
314 ax.set_xticklabels(days)
315 ax.set_xlabel('Day of week')
316 ax.set_ylabel(name)
317 if m.seasonalities[name]['mode'] == 'multiplicative':
318 ax = set_y_as_percent(ax)
319 return artists
320
321
322def plot_yearly(m, ax=None, uncertainty=True, yearly_start=0, figsize=(10, 6), name='yearly'):

Callers 1

plot_componentsFunction · 0.85

Calls 4

seasonality_plot_dfFunction · 0.85
set_y_as_percentFunction · 0.85
plotMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…