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

Skip to content

Commit 1424072

Browse files
committed
[3032853] Hist autorange bug using log and histtype
svn path=/branches/v1_0_maint/; revision=8588
1 parent 85fa9d8 commit 1424072

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/matplotlib/axes.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7699,13 +7699,15 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
76997699

77007700
x[0::2], x[1::2] = bins, bins
77017701

7702+
minimum = min(bins)
7703+
77027704
if align == 'left' or align == 'center':
77037705
x -= 0.5*(bins[1]-bins[0])
77047706
elif align == 'right':
77057707
x += 0.5*(bins[1]-bins[0])
77067708

77077709
if log:
7708-
y[0],y[-1] = 1e-100, 1e-100
7710+
y[0],y[-1] = minimum, minimum
77097711
if orientation == 'horizontal':
77107712
self.set_xscale('log')
77117713
else: # orientation == 'vertical'
@@ -7716,7 +7718,7 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
77167718
for m, c in zip(n, color):
77177719
y[1:-1:2], y[2::2] = m, m
77187720
if log:
7719-
y[y<1e-100]=1e-100
7721+
y[y<minimum]=minimum
77207722
if orientation == 'horizontal':
77217723
x,y = y,x
77227724

@@ -7729,19 +7731,19 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
77297731

77307732
# adopted from adjust_x/ylim part of the bar method
77317733
if orientation == 'horizontal':
7732-
xmin0 = max(_saved_bounds[0]*0.9, 1e-100)
7734+
xmin0 = max(_saved_bounds[0]*0.9, minimum)
77337735
xmax = self.dataLim.intervalx[1]
77347736
for m in n:
77357737
xmin = np.amin(m[m!=0]) # filter out the 0 height bins
7736-
xmin = max(xmin*0.9, 1e-100)
7738+
xmin = max(xmin*0.9, minimum)
77377739
xmin = min(xmin0, xmin)
77387740
self.dataLim.intervalx = (xmin, xmax)
77397741
elif orientation == 'vertical':
7740-
ymin0 = max(_saved_bounds[1]*0.9, 1e-100)
7742+
ymin0 = max(_saved_bounds[1]*0.9, minimum)
77417743
ymax = self.dataLim.intervaly[1]
77427744
for m in n:
77437745
ymin = np.amin(m[m!=0]) # filter out the 0 height bins
7744-
ymin = max(ymin*0.9, 1e-100)
7746+
ymin = max(ymin*0.9, minimum)
77457747
ymin = min(ymin0, ymin)
77467748
self.dataLim.intervaly = (ymin, ymax)
77477749

0 commit comments

Comments
 (0)