From a48f118b91ce3d8b7d1ecf777d08980e5a698301 Mon Sep 17 00:00:00 2001 From: jonathankoch99 Date: Wed, 8 Jan 2025 14:28:41 +0100 Subject: [PATCH 1/4] title as parameter for TimeSeries.plot() --- darts/timeseries.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/darts/timeseries.py b/darts/timeseries.py index 6f2597dd15..dce6127a29 100644 --- a/darts/timeseries.py +++ b/darts/timeseries.py @@ -4077,6 +4077,7 @@ def plot( low_quantile: Optional[float] = 0.05, high_quantile: Optional[float] = 0.95, default_formatting: bool = True, + title: Optional[str] = None, label: Optional[Union[str, Sequence[str]]] = "", max_nr_components: int = 10, ax: Optional[matplotlib.axes.Axes] = None, @@ -4106,6 +4107,8 @@ def plot( interval is shown if `high_quantile` is None (default 0.95). default_formatting Whether to use the darts default scheme. + title + The title of the plot. label Can either be a string or list of strings. If a string and the series only has a single component, it is used as the label for that component. If a string and the series has multiple components, it is used as @@ -4254,7 +4257,7 @@ def plot( ) ax.legend() - ax.set_title(self._xa.name) + ax.set_title(title if title else self._xa.name) return ax def with_columns_renamed( From d8d1a4211132a00992c7bf98f27b49e7ba75012e Mon Sep 17 00:00:00 2001 From: jonathankoch99 Date: Wed, 8 Jan 2025 16:15:38 +0100 Subject: [PATCH 2/4] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34a0eb3038..493264ef50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ but cannot always guarantee backwards compatibility. Changes that may **break co **Improved** - New model: `StatsForecastAutoTBATS`. This model offers the [AutoTBATS](https://nixtlaverse.nixtla.io/statsforecast/src/core/models.html#autotbats) model from Nixtla's `statsforecasts` library. [#2611](https://github.com/unit8co/darts/pull/2611) by [He Weilin](https://github.com/cnhwl). +- Added the `title` attribute to `TimeSeries.plot()`. This allows to set a title for the plot. [#2639](https://github.com/unit8co/darts/pull/2639) by [Jonathan Koch](https://github.com/jonathankoch99). **Fixed** - Fixed a bug when performing optimized historical forecasts with `stride=1` using a `RegressionModel` with `output_chunk_shift>=1` and `output_chunk_length=1`, where the forecast time index was not properly shifted. [#2634](https://github.com/unit8co/darts/pull/2634) by [Mattias De Charleroy](https://github.com/MattiasDC). From 89b462c9bee4628292f2c25f31d09b7c0b688a2c Mon Sep 17 00:00:00 2001 From: Jonathan Koch <64044163+jonathankoch99@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:26:31 +0100 Subject: [PATCH 3/4] Update darts/timeseries.py Co-authored-by: Dennis Bader --- darts/timeseries.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/darts/timeseries.py b/darts/timeseries.py index dce6127a29..7e5098625f 100644 --- a/darts/timeseries.py +++ b/darts/timeseries.py @@ -4257,7 +4257,7 @@ def plot( ) ax.legend() - ax.set_title(title if title else self._xa.name) + ax.set_title(title if title is not None else self._xa.name) return ax def with_columns_renamed( From 435de60f53e0a7696f063b7008eb80d81cb7a195 Mon Sep 17 00:00:00 2001 From: Jonathan Koch <64044163+jonathankoch99@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:26:42 +0100 Subject: [PATCH 4/4] Update darts/timeseries.py Co-authored-by: Dennis Bader --- darts/timeseries.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/darts/timeseries.py b/darts/timeseries.py index 7e5098625f..4b7940e91f 100644 --- a/darts/timeseries.py +++ b/darts/timeseries.py @@ -4108,7 +4108,7 @@ def plot( default_formatting Whether to use the darts default scheme. title - The title of the plot. + Optionally, a custom plot title. If `None`, will use the name of the underlying `xarray.DataArray`. label Can either be a string or list of strings. If a string and the series only has a single component, it is used as the label for that component. If a string and the series has multiple components, it is used as