Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 81e7f14

Browse files
authored
Merge pull request #23989 from meeseeksmachine/auto-backport-of-pr-23944-on-v3.6.x
Backport PR #23944 on branch v3.6.x (FIX: ValueError when hexbin is run with empty arrays and log scaling.)
2 parents 6b4a793 + c633956 commit 81e7f14

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4927,7 +4927,9 @@ def reduce_C_function(C: array) -> float
49274927
# autoscale the norm with current accum values if it hasn't been set
49284928
if norm is not None:
49294929
if norm.vmin is None and norm.vmax is None:
4930-
norm.autoscale(accum)
4930+
norm.autoscale_None(accum)
4931+
norm.vmin = np.ma.masked if norm.vmin is None else norm.vmin
4932+
norm.vmax = np.ma.masked if norm.vmax is None else norm.vmax
49314933

49324934
if bins is not None:
49334935
if not np.iterable(bins):

lib/matplotlib/tests/test_axes.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,14 @@ def test_hexbin_empty():
901901
ax.hexbin([], [])
902902

903903

904+
@image_comparison(['hexbin_empty.png'], remove_text=True)
905+
def test_hexbin_log_empty():
906+
# From #23922: creating hexbin with log scaling from empty
907+
# dataset raises ValueError
908+
ax = plt.gca()
909+
ax.hexbin([], [], bins='log')
910+
911+
904912
def test_hexbin_pickable():
905913
# From #1973: Test that picking a hexbin collection works
906914
fig, ax = plt.subplots()

0 commit comments

Comments
 (0)