From a6646670b9c5e6ac297b2d83debb9dafcba3700a Mon Sep 17 00:00:00 2001 From: Maxim Grishin Date: Fri, 25 Oct 2019 23:42:58 +0300 Subject: [PATCH] Fix plotting with 0 changepoints --- python/fbprophet/plot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/fbprophet/plot.py b/python/fbprophet/plot.py index 80663b6..a8492d0 100644 --- a/python/fbprophet/plot.py +++ b/python/fbprophet/plot.py @@ -441,7 +441,7 @@ def add_changepoints_to_plot( artists.append(ax.plot(fcst['ds'], fcst['trend'], c=cp_color)) signif_changepoints = m.changepoints[ np.abs(np.nanmean(m.params['delta'], axis=0)) >= threshold - ] + ] if len(m.changepoints) > 0 else [] for cp in signif_changepoints: artists.append(ax.axvline(x=cp, c=cp_color, ls=cp_linestyle)) return artists @@ -628,7 +628,7 @@ def plot_plotly(m, fcst, uncertainty=True, plot_cap=True, trend=False, changepoi line=dict(color=trend_color, width=line_width), )) # Add changepoints - if changepoints: + if changepoints and len(m.changepoints) > 0: signif_changepoints = m.changepoints[ np.abs(np.nanmean(m.params['delta'], axis=0)) >= changepoints_threshold ]