@@ -8184,19 +8184,33 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
8184
8184
8185
8185
x [0 ::2 ], x [1 ::2 ] = bins , bins
8186
8186
8187
- minimum = np .min (n )
8188
-
8189
- if align == 'left' or align == 'center' :
8190
- x -= 0.5 * (bins [1 ]- bins [0 ])
8191
- elif align == 'right' :
8192
- x += 0.5 * (bins [1 ]- bins [0 ])
8193
-
8194
8187
if log :
8195
- y [0 ],y [- 1 ] = minimum , minimum
8196
8188
if orientation == 'horizontal' :
8197
8189
self .set_xscale ('log' )
8190
+ logbase = self .xaxis ._scale .base
8198
8191
else : # orientation == 'vertical'
8199
8192
self .set_yscale ('log' )
8193
+ logbase = self .yaxis ._scale .base
8194
+
8195
+ # Setting a minimum of 0 results in problems for log plots
8196
+ if normed :
8197
+ # For normed data, set to log base * minimum data value
8198
+ # (gives 1 full tick-label unit for the lowest filled bin)
8199
+ ndata = np .array (n )
8200
+ minimum = (np .min (ndata [ndata > 0 ])) / logbase
8201
+ else :
8202
+ # For non-normed data, set the min to log base, again so that
8203
+ # there is 1 full tick-label unit for the lowest bin
8204
+ minimum = 1.0 / logbase
8205
+
8206
+ y [0 ], y [- 1 ] = minimum , minimum
8207
+ else :
8208
+ minimum = np .min (bins )
8209
+
8210
+ if align == 'left' or align == 'center' :
8211
+ x -= 0.5 * (bins [1 ]- bins [0 ])
8212
+ elif align == 'right' :
8213
+ x += 0.5 * (bins [1 ]- bins [0 ])
8200
8214
8201
8215
# If fill kwarg is set, it will be passed to the patch collection,
8202
8216
# overriding this
0 commit comments