8000 FIX: if bins input to hist is str, treat like no bins · matplotlib/matplotlib@dab2a16 · GitHub
[go: up one dir, main page]

Skip to content

Commit dab2a16

Browse files
committed
FIX: if bins input to hist is str, treat like no bins
This change causes the range of all data sets to be computed and passed to numpy (which in turn uses the total range to compute the 'best' bins). The existing code 'latches' the bins from the first data set to use for the rest so this is can still lead to poor binning (if the data sets are widely different). closes #8636
1 parent 867c3dd commit dab2a16

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6637,7 +6637,9 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
66376637
bin_range = self.convert_xunits(bin_range)
66386638

66396639
# Check whether bins or range are given explicitly.
6640-
binsgiven = np.iterable(bins) or bin_range is not None
6640+
binsgiven = ((np.iterable(bins) and
6641+
not isinstance(bins, str)) or
6642+
bin_range is not None)
66416643

66426644
# We need to do to 'weights' what was done to 'x'
66436645
if weights is not None:

0 commit comments

Comments
 (0)
0