Skip to content

Commit cc55b33

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 f0ccf7e commit cc55b33

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/matplotlib/axes/_axes.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -6044,7 +6044,9 @@ def hist(self, x, bins=None, range=None, normed=False, weights=None,
60446044
bin_range = self.convert_xunits(bin_range)
60456045

60466046
# Check whether bins or range are given explicitly.
6047-
binsgiven = (cbook.iterable(bins) or bin_range is not None)
6047+
binsgiven = ((cbook.iterable(bins) and
6048+
not isinstance(bins, six.string_types)) or
6049+
bin_range is not None)
60486050

60496051
# basic input validation
60506052
input_empty = np.size(x) == 0

0 commit comments

Comments
 (0)