Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0636b9e

Browse filesBrowse files
authored
FIX: ValueError when hexbin is run with empty arrays and log scaling. (#23944)
* Add test for empty hexbin with log scaling. * Use guarded autoscale_None for use when vmin/vmax are None. * Add additional check when auto vmin/vmax are None.
1 parent 33303ba commit 0636b9e
Copy full SHA for 0636b9e

File tree

Expand file treeCollapse file tree

2 files changed

+11
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-1
lines changed
Open diff view settings
Collapse file

‎lib/matplotlib/axes/_axes.py‎

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4943,7 +4943,9 @@ def reduce_C_function(C: array) -> float
49434943
# autoscale the norm with current accum values if it hasn't been set
49444944
if norm is not None:
49454945
if norm.vmin is None and norm.vmax is None:
4946-
norm.autoscale(accum)
4946+
norm.autoscale_None(accum)
4947+
norm.vmin = np.ma.masked if norm.vmin is None else norm.vmin
4948+
norm.vmax = np.ma.masked if norm.vmax is None else norm.vmax
49474949

49484950
if bins is not None:
49494951
if not np.iterable(bins):
Collapse file

‎lib/matplotlib/tests/test_axes.py‎

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+8Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.