diff --git a/doc/api/next_api_changes/behavior/21038-DS.rst b/doc/api/next_api_changes/behavior/21038-DS.rst new file mode 100644 index 000000000000..55ca3fb7597d --- /dev/null +++ b/doc/api/next_api_changes/behavior/21038-DS.rst @@ -0,0 +1,4 @@ +hexbin with a log norm +---------------------- +`~.axes.Axes.hexbin` no longer (incorrectly) adds 1 to every bin value if a +log norm is being used. diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 257ae2fe4839..8e42430d68b7 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -4803,11 +4803,6 @@ def reduce_C_function(C: array) -> float vmin = vmax = None bins = None - if isinstance(norm, mcolors.LogNorm): - if (accum == 0).any(): - # make sure we have no zeros - accum += 1 - # autoscale the norm with current accum values if it hasn't # been set if norm is not None: diff --git a/lib/matplotlib/tests/baseline_images/test_axes/hexbin_log.png b/lib/matplotlib/tests/baseline_images/test_axes/hexbin_log.png index febefb870918..1dc46d9f4d5b 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_axes/hexbin_log.png and b/lib/matplotlib/tests/baseline_images/test_axes/hexbin_log.png differ