diff --git a/R/R/plot.R b/R/R/plot.R index 7d0f13e..b2a5e48 100644 --- a/R/R/plot.R +++ b/R/R/plot.R @@ -113,7 +113,7 @@ prophet_plot_components <- function( panels[[length(panels) + 1]] <- plot_yearly(m, uncertainty, yearly_start) } # Plot other seasonalities - for (name in names(m$seasonalities)) { + for (name in sort(names(m$seasonalities))) { if (!(name %in% c('weekly', 'yearly')) && (name %in% colnames(fcst))) { panels[[length(panels) + 1]] <- plot_seasonality(m, name, uncertainty) diff --git a/python/fbprophet/plot.py b/python/fbprophet/plot.py index 1dced4f..358b399 100644 --- a/python/fbprophet/plot.py +++ b/python/fbprophet/plot.py @@ -105,8 +105,17 @@ def plot_components( components = ['trend'] if m.train_holiday_names is not None and 'holidays' in fcst: components.append('holidays') - components.extend([name for name in m.seasonalities - if name in fcst]) + # Plot weekly seasonality, if present + if 'weekly' in m.seasonalities and 'weekly' in fcst: + components.append('weekly') + # Yearly if present + if 'yearly' in m.seasonalities and 'yearly' in fcst: + components.append('yearly') + # Other seasonalities + components.extend([ + name for name in sorted(m.seasonalities) + if name in fcst and name not in ['weekly', 'yearly'] + ]) regressors = {'additive': False, 'multiplicative': False} for name, props in m.extra_regressors.items(): regressors[props['mode']] = True