From 281b09d62f43e1e64a16c76747d70d402ad52f92 Mon Sep 17 00:00:00 2001 From: Eli Rykoff Date: Sun, 18 Sep 2022 21:48:52 -0700 Subject: [PATCH 1/3] Add test for empty hexbin with log scaling. --- lib/matplotlib/tests/test_axes.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 405560d4a386..8e12cad044dc 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -901,6 +901,14 @@ def test_hexbin_empty(): ax.hexbin([], []) +@image_comparison(['hexbin_empty.png'], remove_text=True) +def test_hexbin_log_empty(): + # From #23922: creating hexbin with log scaling from empty + # dataset raises ValueError + ax = plt.gca() + ax.hexbin([], [], bins='log') + + def test_hexbin_pickable(): # From #1973: Test that picking a hexbin collection works fig, ax = plt.subplots() From c8b5deaae84944a49a670fe5f0216918b7344508 Mon Sep 17 00:00:00 2001 From: Eli Rykoff Date: Mon, 19 Sep 2022 08:46:19 -0700 Subject: [PATCH 2/3] Use guarded autoscale_None for use when vmin/vmax are None. --- lib/matplotlib/axes/_axes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index c99b0771e2f1..c76ef4a52d1e 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -4943,7 +4943,7 @@ def reduce_C_function(C: array) -> float # autoscale the norm with current accum values if it hasn't been set if norm is not None: if norm.vmin is None and norm.vmax is None: - norm.autoscale(accum) + norm.autoscale_None(accum) if bins is not None: if not np.iterable(bins): From 3d2ffef00b2faed523be80ef98bb7e2c051897ad Mon Sep 17 00:00:00 2001 From: Eli Rykoff Date: Mon, 19 Sep 2022 09:43:55 -0700 Subject: [PATCH 3/3] Add additional check when auto vmin/vmax are None. --- lib/matplotlib/axes/_axes.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index c76ef4a52d1e..afc5a71059e7 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -4944,6 +4944,8 @@ def reduce_C_function(C: array) -> float if norm is not None: if norm.vmin is None and norm.vmax is None: norm.autoscale_None(accum) + norm.vmin = np.ma.masked if norm.vmin is None else norm.vmin + norm.vmax = np.ma.masked if norm.vmax is None else norm.vmax if bins is not None: if not np.iterable(bins): pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy