We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3e5dd6e commit bd84186Copy full SHA for bd84186
doc/whats-new.rst
@@ -91,6 +91,8 @@ Bug fixes
91
By `Deepak Cherian <https://github.com/dcherian>`_
92
- Fix :py:class:`~xarray.plot.FacetGrid` when ``vmin == vmax``. (:issue:`3734`)
93
94
+- Fix plotting when ``levels`` is a scalar and ``norm`` is provided. (:issue:`3735`)
95
+ By `Deepak Cherian <https://github.com/dcherian>`_
96
- Fix bug where plotting line plots with 2D coordinates depended on dimension
97
order. (:issue:`3933`)
98
By `Tom Nicholas <https://github.com/TomNicholas>`_.
xarray/plot/utils.py
@@ -268,7 +268,7 @@ def _determine_cmap_params(
268
cmap = OPTIONS["cmap_sequential"]
269
270
# Handle discrete levels
271
- if levels is not None and norm is None:
+ if levels is not None:
272
if is_scalar(levels):
273
if user_minmax:
274
levels = np.linspace(vmin, vmax, levels)
xarray/tests/test_plot.py
@@ -854,21 +854,22 @@ def test_norm_sets_vmin_vmax(self):
854
vmin = self.data.min()
855
vmax = self.data.max()
856
857
- for norm, extend in zip(
+ for norm, extend, levels in zip(
858
[
859
+ mpl.colors.Normalize(),
860
mpl.colors.Normalize(),
861
mpl.colors.Normalize(vmin + 0.1, vmax - 0.1),
862
mpl.colors.Normalize(None, vmax - 0.1),
863
mpl.colors.Normalize(vmin + 0.1, None),
864
],
- ["neither", "both", "max", "min"],
865
+ ["neither", "neither", "both", "max", "min"],
866
+ [7, None, None, None, None],
867
):
868
869
test_min = vmin if norm.vmin is None else norm.vmin
870
test_max = vmax if norm.vmax is None else norm.vmax
871
- cmap_params = _determine_cmap_params(self.data, norm=norm)
-
872
+ cmap_params = _determine_cmap_params(self.data, norm=norm, levels=levels)
873
assert cmap_params["vmin"] == test_min
874
assert cmap_params["vmax"] == test_max
875
assert cmap_params["extend"] == extend
0 commit comments