Skip to content

Commit

Permalink
Update dataset_plot.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Illviljan committed Jul 6, 2024
1 parent 7deb2af commit 609b1c7
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions xarray/plot/dataset_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ def _temp_dataarray(ds: Dataset, y: Hashable, locals_: dict[str, Any]) -> DataAr
from xarray.core.dataarray import DataArray

coords = dict(ds[y].coords)
dims = dict.fromkeys(ds[y].dims)
dims = set(ds[y].dims)

# Add extra coords to the DataArray from valid kwargs, if using all
# kwargs there is a risk that we add unnecessary dataarrays as
Expand All @@ -735,11 +735,10 @@ def _temp_dataarray(ds: Dataset, y: Hashable, locals_: dict[str, Any]) -> DataAr
darray = ds.get(key)
if darray is not None:
coords[key] = darray
for d in darray.dims:
dims[d] = None
dims.update(darray.dims)

# Trim dataset from unneccessary dims:
ds_trimmed = ds.drop_dims(ds.dims - dims.keys())
ds_trimmed = ds.drop_dims(ds.sizes.keys() - dims) # TODO: Use ds.dims in the future

# The dataarray has to include all the dims. Broadcast to that shape
# and add the additional coords:
Expand Down

0 comments on commit 609b1c7

Please sign in to comment.