Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5232,18 +5232,18 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
hist_kwargs = dict(range=bin_range)

n = []
mlast = bottom
mlast = None
for i in xrange(nx):
# this will automatically overwrite bins,
# so that each histogram uses the same bins
m, bins = np.histogram(x[i], bins, weights=w[i], **hist_kwargs)
m = m.astype(float) # causes problems later if it's an int
if mlast is None:
mlast = np.zeros(len(bins)-1, m.dtype)
if normed and not stacked:
db = np.diff(bins)
m = (m.astype(float) / db) / m.sum()
if stacked:
if mlast is None:
mlast = np.zeros(len(bins)-1, m.dtype)
m += mlast
mlast[:] = m
n.append(m)
Expand Down Expand Up @@ -5334,6 +5334,12 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
x[0:2*len(bins)-1:2], x[1:2*len(bins)-1:2] = bins, bins[:-1]
x[2*len(bins)-1:] = x[1:2*len(bins)-1][::-1]

if bottom is None:
bottom = np.zeros(len(bins)-1, np.float)

y[1:2*len(bins)-1:2], y[2:2*len(bins):2] = bottom, bottom
y[2*len(bins)-1:] = y[1:2*len(bins)-1][::-1]

if log:
if orientation == 'horizontal':
self.set_xscale('log', nonposx='clip')
Expand Down Expand Up @@ -5369,12 +5375,13 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,

xvals, yvals = [], []
for m in n:
# starting point for drawing polygon
y[0] = y[-1]
# top of the previous polygon becomes the bottom
y[2*len(bins)-1:] = y[1:2*len(bins)-1][::-1]
if stacked:
# starting point for drawing polygon
y[0] = y[-1]
# top of the previous polygon becomes the bottom
y[2*len(bins)-1:] = y[1:2*len(bins)-1][::-1]
# set the top of this polygon
y[1:2*len(bins)-1:2], y[2:2*len(bins):2] = m, m
y[1:2*len(bins)-1:2], y[2:2*len(bins):2] = m+bottom, m+bottom
if log:
y[y < minimum] = minimum
if orientation == 'horizontal':
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading