FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix hist for log=True and histtype='step' by dmcdougall · Pull Request #1684 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .pdf  (1) .png  (1) .py  (2) .svg  (1) All 4 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
30 changes: 22 additions & 8 deletions lib/matplotlib/axes.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -8184,19 +8184,33 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,

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

minimum = np.min(n)

if align == 'left' or align == 'center':
x -= 0.5*(bins[1]-bins[0])
elif align == 'right':
x += 0.5*(bins[1]-bins[0])

if log:
y[0],y[-1] = minimum, minimum
if orientation == 'horizontal':
self.set_xscale('log')
logbase = self.xaxis._scale.base
else: # orientation == 'vertical'
self.set_yscale('log')
logbase = self.yaxis._scale.base

# Setting a minimum of 0 results in problems for log plots
if normed:
# For normed data, set to log base * minimum data value
# (gives 1 full tick-label unit for the lowest filled bin)
ndata = np.array(n)
minimum = (np.min(ndata[ndata>0])) / logbase
else:
# For non-normed data, set the min to log base, again so that
# there is 1 full tick-label unit for the lowest bin
minimum = 1.0 / logbase

y[0], y[-1] = minimum, minimum
else:
minimum = np.min(bins)

if align == 'left' or align == 'center':
x -= 0.5*(bins[1]-bins[0])
elif align == 'right':
x += 0.5*(bins[1]-bins[0])

# If fill kwarg is set, it will be passed to the patch collection,
# overriding this
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.
Viewer requires iframe.
Loading

Back | FazBrowse Home | New Git URL