From 9a8b33fbe15702d2113fa4e1c792ff230e9367be Mon Sep 17 00:00:00 2001 From: Michael Niklas Date: Sun, 12 Mar 2023 21:58:10 +0100 Subject: [PATCH 1/2] add a test for scatter colorbar extend --- xarray/tests/test_plot.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xarray/tests/test_plot.py b/xarray/tests/test_plot.py index 40204691e85..f0eb318ab8e 100644 --- a/xarray/tests/test_plot.py +++ b/xarray/tests/test_plot.py @@ -2110,6 +2110,12 @@ def test_colorbar(self) -> None: assert 1 == len(find_possible_colorbars()) + def test_colorbar_scatter(self) -> None: + ds = Dataset({"a": (("x", "y"), np.arange(4).reshape(2, 2))}) + fg = ds.plot.scatter(x="a", y="a", row="x", hue="a") + assert fg.cbar.vmin == 0 + assert fg.cbar.vmax == 3 + @pytest.mark.slow def test_empty_cell(self) -> None: g = xplt.FacetGrid(self.darray, col="z", col_wrap=2) From 0b1773d68547f5d75e65ed32c73c56f36deb37d0 Mon Sep 17 00:00:00 2001 From: Michael Niklas Date: Sun, 12 Mar 2023 22:19:56 +0100 Subject: [PATCH 2/2] fix mypy issues --- xarray/tests/test_plot.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xarray/tests/test_plot.py b/xarray/tests/test_plot.py index f0eb318ab8e..f736a851d7e 100644 --- a/xarray/tests/test_plot.py +++ b/xarray/tests/test_plot.py @@ -2112,9 +2112,11 @@ def test_colorbar(self) -> None: def test_colorbar_scatter(self) -> None: ds = Dataset({"a": (("x", "y"), np.arange(4).reshape(2, 2))}) - fg = ds.plot.scatter(x="a", y="a", row="x", hue="a") - assert fg.cbar.vmin == 0 - assert fg.cbar.vmax == 3 + fg: xplt.FacetGrid = ds.plot.scatter(x="a", y="a", row="x", hue="a") + cbar = fg.cbar + assert cbar is not None + assert cbar.vmin == 0 + assert cbar.vmax == 3 @pytest.mark.slow def test_empty_cell(self) -> None: