From 5784eb6a990a6c56d458d84aa3a57f80c695c073 Mon Sep 17 00:00:00 2001 From: "Matthew R. Becker" Date: Wed, 27 Aug 2025 14:01:25 -0500 Subject: [PATCH] =?UTF-8?q?Revert=20"Fix=20edge=20case=20where=20vcenter?= =?UTF-8?q?=20is=20not=20properly=20set=20for=20diverging=20norms=20(?= =?UTF-8?q?=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 644e1d08dd52b7b6f3f38bc51aba8ab1942729b8. --- ultraplot/axes/plot.py | 8 +------- ultraplot/tests/test_color.py | 37 ----------------------------------- 2 files changed, 1 insertion(+), 44 deletions(-) delete mode 100644 ultraplot/tests/test_color.py diff --git a/ultraplot/axes/plot.py b/ultraplot/axes/plot.py index 3f29d190b..df902902e 100644 --- a/ultraplot/axes/plot.py +++ b/ultraplot/axes/plot.py @@ -2707,13 +2707,6 @@ def _parse_cmap( # Create the continuous normalizer. norm = _not_none(norm, "div" if "diverging" in trues else "linear") - # If using a diverging norm, fair=True, and vcenter not set, default to midpoint - if norm in ("div", "diverging") or "diverging" in trues: - fair = norm_kw.get("fair", True) # defaults to True - vcenter = norm_kw.get("vcenter", 0) - if fair and vcenter is None and vmin is not None and vmax is not None: - vcenter = 0.5 * (vmin + vmax) - norm_kw["vcenter"] = vcenter if isinstance(norm, mcolors.Normalize): norm.vmin, norm.vmax = vmin, vmax else: @@ -2946,6 +2939,7 @@ def _parse_level_lim( f"Incompatible arguments vmin={vmin!r}, vmax={vmax!r}, and " "symmetric=True. Ignoring the latter." ) + return vmin, vmax, kwargs def _parse_level_num( diff --git a/ultraplot/tests/test_color.py b/ultraplot/tests/test_color.py deleted file mode 100644 index 61e83a464..000000000 --- a/ultraplot/tests/test_color.py +++ /dev/null @@ -1,37 +0,0 @@ -import ultraplot as uplt, numpy as np, pytest - - -@pytest.mark.mpl_image_compare -def test_vcenter_values(): - """ - Test that vcenter values are correctly set in colorbars. - """ - rng = np.random.default_rng(seed=10) - mvals = rng.normal(size=(32, 32)) - cmap = "spectral" - # The middle and right plot should look the same - # The colors should spread out where the extremes are visible - fig, axs = uplt.subplots(ncols=3, share=0) - for i, ax in enumerate(axs): - specs = {} - if i > 0: - vmin = -0.2 - vmax = 2.0 - specs = dict(vmin=vmin, vmax=vmax) - if i == 2: - mvals = np.clip(mvals, vmin, vmax) - m = ax.pcolormesh( - mvals, - cmap=cmap, - discrete=False, - **specs, - ) - ax.format( - grid=False, - xticklabels=[], - xticks=[], - yticklabels=[], - yticks=[], - ) - ax.colorbar(m, loc="r", label=f"{i}") - return fig