diff --git a/lib/matplotlib/axes.py b/lib/matplotlib/axes.py index 82def00583ed..d2f48855343a 100644 --- a/lib/matplotlib/axes.py +++ b/lib/matplotlib/axes.py @@ -7861,7 +7861,19 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None, x[0::2], x[1::2] = bins, bins - minimum = min(bins) + if log: + # setting a minimum of 0 results in problems for log plots + if normed: + # for normed data, set to 0.1 * minimum data value + # (gives 1 full dex for the lowest filled bin) + ndata = np.array(n) + minimum = (ndata[ndata>0].min())*0.1 + else: + # for non-normed data, set the min to 0.1, again so that + # there is 1 full dex for the lowest bin + minimum = 0.1 + else: + minimum = min(bins) if align == 'left' or align == 'center': x -= 0.5*(bins[1]-bins[0])