diff --git a/python/prophet/plot.py b/python/prophet/plot.py index 3e7efb9d7..bb9bdc2a6 100644 --- a/python/prophet/plot.py +++ b/python/prophet/plot.py @@ -309,7 +309,10 @@ def seasonality_plot_df( ------- A dataframe with seasonal components on ds. """ - df_dict = {'ds': ds, 'cap': 1., 'floor': 0.} + cap = 1.0 + if m.scaling == "minmax" and not m.logistic_floor and m.y_min is not None: + cap = float(m.y_min) + 1.0 + df_dict = {'ds': ds, 'cap': cap, 'floor': 0.} for name in m.extra_regressors: df_dict[name] = 0. # Activate all conditional seasonality columns diff --git a/python/prophet/tests/test_plot.py b/python/prophet/tests/test_plot.py index e3df0489d..aa15fc17d 100644 --- a/python/prophet/tests/test_plot.py +++ b/python/prophet/tests/test_plot.py @@ -201,3 +201,17 @@ def test_plotly_draws_data(self, model_and_forecast): traces = get_seasonality_plotly_props(m, "weekly")["traces"] np.testing.assert_array_equal(pd.to_datetime(traces[0].x), data["ds"]) np.testing.assert_array_equal(traces[0].y, data["weekly"]) + + def test_seasonality_plot_df_logistic_minmax_without_floor(self): + m = Prophet(growth="logistic", scaling="minmax") + df = pd.DataFrame({ + "ds": pd.date_range("2020-01-01", periods=20), + "y": np.linspace(100.0, 150.0, 20), + "cap": 200.0, + }) + m.fit(df) + days = pd.date_range("2020-01-01", periods=7) + plot_df = seasonality_plot_df(m, days) + assert len(plot_df) == 7 + assert (plot_df["cap"] > plot_df["floor"]).all() +