Skip to content

Commit

Permalink
fixes bug when plotting multivariate probabilistic series where the c… (
Browse files Browse the repository at this point in the history
#2532)

* fixes bug when plotting multivariate probabilistic series where the confidence intervals had the same color as central series

* add labels back

* update changelog
  • Loading branch information
dennisbader authored Sep 15, 2024
1 parent 5740da5 commit 41e1177
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ but cannot always guarantee backwards compatibility. Changes that may **break co

**Fixed**

- Fixed bug when plotting a probabilistic multivariate series, where all confidence intervals (starting from 2nd component) had the same color as the median line. [#2532](https://github.com/unit8co/darts/pull/2532) by [Dennis Bader](https://github.com/dennisbader).
- Fixed a bug when passing an empty array to `TimeSeries.prepend/append_values()` raised an error. [#2522](https://github.com/unit8co/darts/pull/2522) by [Alessio Pellegrini](https://github.com/AlessiopSymplectic)
- Fixed a bug with `TimeSeries.prepend/append_values()`, where the name of the (time) index was lost. [#2522](https://github.com/unit8co/darts/pull/2522) by [Alessio Pellegrini](https://github.com/AlessiopSymplectic)
- Fixed a bug when using `from_group_dataframe()` with a `time_col` of type integer, where the resulting time index was wrongly converted to a DatetimeIndex. [#2512](https://github.com/unit8co/darts/pull/2512) by [Alessio Pellegrini](https://github.com/AlessiopSymplectic)
Expand Down
11 changes: 6 additions & 5 deletions darts/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -4191,8 +4191,6 @@ def plot(
central_series = comp.mean(dim=DIMS[2])

alpha = kwargs["alpha"] if "alpha" in kwargs else None
if not self.is_deterministic:
kwargs["alpha"] = 1
if custom_labels:
label_to_use = label[i]
else:
Expand All @@ -4204,15 +4202,18 @@ def plot(
label_to_use = f"{label}_{comp_name}"
kwargs["label"] = label_to_use

kwargs_central = deepcopy(kwargs)
if not self.is_deterministic:
kwargs_central["alpha"] = 1
if central_series.shape[0] > 1:
p = central_series.plot(*args, ax=ax, **kwargs)
p = central_series.plot(*args, ax=ax, **kwargs_central)
# empty TimeSeries
elif central_series.shape[0] == 0:
p = ax.plot(
[],
[],
*args,
**kwargs,
**kwargs_central,
)
ax.set_xlabel(self.time_index.name)
else:
Expand All @@ -4221,7 +4222,7 @@ def plot(
central_series.values[0],
"o",
*args,
**kwargs,
**kwargs_central,
)
color_used = p[0].get_color() if default_formatting else None

Expand Down

0 comments on commit 41e1177

Please sign in to comment.