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

Skip to content

Commit 0c8e9d8

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 019aeea commit 0c8e9d8

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
@@ -6612,7 +6612,9 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
66126612
bin_range = self.convert_xunits(bin_range)
66136613

66146614
# Check whether bins or range are given explicitly.
6615-
binsgiven = np.iterable(bins) or bin_range is not None
6615+
binsgiven = ((np.iterable(bins) and
6616+
not isinstance(bins, str)) or
6617+
bin_range is not None)
66166618

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

0 commit comments

Comments
 (0)