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

Skip to content

Commit de1be12

Browse files
authored
Merge pull request matplotlib#27441 from QuLogic/hexbin-bins
Fix some minor issues with hexbin bins argument
2 parents bc1c5cc + 14dc7a8 commit de1be12

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

galleries/examples/statistics/hexbin_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
hb = ax1.hexbin(x, y, gridsize=50, bins='log', cmap='inferno')
3030
ax1.set(xlim=xlim, ylim=ylim)
3131
ax1.set_title("With a log color scale")
32-
cb = fig.colorbar(hb, ax=ax1, label='log10(N)')
32+
cb = fig.colorbar(hb, ax=ax1, label='counts')
3333

3434
plt.show()
3535

lib/matplotlib/axes/_axes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5103,10 +5103,10 @@ def reduce_C_function(C: array) -> float
51035103
)
51045104

51055105
# Set normalizer if bins is 'log'
5106-
if bins == 'log':
5106+
if cbook._str_equal(bins, 'log'):
51075107
if norm is not None:
51085108
_api.warn_external("Only one of 'bins' and 'norm' arguments "
5109-
f"can be supplied, ignoring bins={bins}")
5109+
f"can be supplied, ignoring {bins=}")
51105110
else:
51115111
norm = mcolors.LogNorm(vmin=vmin, vmax=vmax)
51125112
vmin = vmax = None

lib/matplotlib/tests/test_axes.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -962,17 +962,18 @@ def test_hexbin_extent():
962962
ax.hexbin("x", "y", extent=[.1, .3, .6, .7], data=data)
963963

964964

965-
@image_comparison(['hexbin_empty.png', 'hexbin_empty.png'], remove_text=True)
965+
@image_comparison(['hexbin_empty.png'], remove_text=True)
966966
def test_hexbin_empty():
967967
# From #3886: creating hexbin from empty dataset raises ValueError
968968
fig, ax = plt.subplots()
969969
ax.hexbin([], [])
970-
fig, ax = plt.subplots()
971970
# From #23922: creating hexbin with log scaling from empty
972971
# dataset raises ValueError
973972
ax.hexbin([], [], bins='log')
974973
# From #27103: np.max errors when handed empty data
975974
ax.hexbin([], [], C=[], reduce_C_function=np.max)
975+
# No string-comparison warning from NumPy.
976+
ax.hexbin([], [], bins=np.arange(10))
976977

977978

978979
def test_hexbin_pickable():

0 commit comments

Comments
 (0)