Restore default behavior of hexbin mincnt with C provided · matplotlib/matplotlib@3d35aa5 · GitHub
Skip to content

Commit 3d35aa5

Browse files
committed
Restore default behavior of hexbin mincnt with C provided
1 parent e501543 commit 3d35aa5

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

doc/api/prev_api_changes/api_changes_3.8.0/behaviour.rst

Lines changed: 6 additions & 0 deletions

lib/matplotlib/axes/_axes.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4873,8 +4873,8 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None,
48734873
yscale : {'linear', 'log'}, default: 'linear'
48744874
Use a linear or log10 scale on the vertical axis.
48754875
4876-
mincnt : int > 0, default: *None*
4877-
If not *None*, only display cells with more than *mincnt*
4876+
mincnt : int >= 0, default: *None*
4877+
If not *None*, only display cells with at least *mincnt*
48784878
number of points in the cell.
48794879
48804880
marginals : bool, default: *False*
@@ -4941,6 +4941,11 @@ def reduce_C_function(C: array) -> float
49414941
- `numpy.sum`: integral of the point values
49424942
- `numpy.amax`: value taken from the largest point
49434943
4944+
By default will only reduce cells with at least 1 point because some
4945+
reduction functions (such as `numpy.amax`) will error/warn with empty
4946+
input. Changing *mincnt* will adjust the cutoff, and if set to 0 will
4947+
pass empty input to the reduction function.
4948+
49444949
data : indexable object, optional
49454950
DATA_PARAMETER_PLACEHOLDER
49464951
@@ -5038,7 +5043,7 @@ def reduce_C_function(C: array) -> float
50385043
else:
50395044
Cs_at_i2[i2[i]].append(C[i])
50405045
if mincnt is None:
5041-
mincnt = 0
5046+
mincnt = 1
50425047
accum = np.array(
50435048
[reduce_C_function(acc) if len(acc) >= mincnt else np.nan
50445049
for Cs_at_i in [Cs_at_i1, Cs_at_i2]

lib/matplotlib/tests/test_axes.py

Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)