Skip to content

Commit 5c39640

Browse files
authored
Fixed color.shape != grid.shape in streamplot when nx != ny (#10411)
1 parent 3610baa commit 5c39640

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

xarray/plot/dataset_plot.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,8 @@ def streamplot(
630630
cmap_params = kwargs.pop("cmap_params")
631631

632632
if hue:
633+
if xdim is not None and ydim is not None:
634+
ds[hue] = ds[hue].transpose(ydim, xdim)
633635
kwargs["color"] = ds[hue].values
634636

635637
# TODO: Fix this by always returning a norm with vmin, vmax in cmap_params

xarray/tests/test_plot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2698,9 +2698,9 @@ class TestDatasetStreamplotPlots(PlotTestCase):
26982698
def setUp(self) -> None:
26992699
das = [
27002700
DataArray(
2701-
np.random.randn(3, 3, 2, 2),
2701+
np.random.randn(3, 4, 2, 2),
27022702
dims=["x", "y", "row", "col"],
2703-
coords=[range(k) for k in [3, 3, 2, 2]],
2703+
coords=[range(k) for k in [3, 4, 2, 2]],
27042704
)
27052705
for _ in [1, 2]
27062706
]

0 commit comments

Comments
 (0)