Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2ca68c6

Browse filesBrowse files
committed
Use actual log base, instead of assuming a default
1 parent 4aa17a7 commit 2ca68c6
Copy full SHA for 2ca68c6

File tree

Expand file treeCollapse file tree

1 file changed

+11
-9
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-9
lines changed

‎lib/matplotlib/axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes.py
+11-9Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8185,16 +8185,25 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
81858185
x[0::2], x[1::2] = bins, bins
81868186

81878187
if log:
8188+
if orientation == 'horizontal':
8189+
self.set_xscale('log')
8190+
logbase = self.xaxis._scale.base
8191+
else: # orientation == 'vertical'
8192+
self.set_yscale('log')
8193+
logbase = self.yaxis._scale.base
8194+
81888195
# setting a minimum of 0 results in problems for log plots
81898196
if normed:
81908197
# for normed data, set to 0.1 * minimum data value
81918198
# (gives 1 full dex for the lowest filled bin)
81928199
ndata = np.array(n)
8193-
minimum = (np.min(ndata[ndata>0]))*0.1
8200+
minimum = (np.min(ndata[ndata>0])) / logbase
81948201
else:
81958202
# for non-normed data, set the min to 0.1, again so that
81968203
# there is 1 full dex for the lowest bin
8197-
minimum = 0.1
8204+
minimum = 1.0 / logbase
8205+
8206+
y[0], y[-1] = minimum, minimum
81988207
else:
81998208
minimum = np.min(bins)
82008209

@@ -8203,13 +8212,6 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
82038212
elif align == 'right':
82048213
x += 0.5*(bins[1]-bins[0])
82058214

8206-
if log:
8207-
y[0],y[-1] = minimum, minimum
8208-
if orientation == 'horizontal':
8209-
self.set_xscale('log')
8210-
else: # orientation == 'vertical'
8211-
self.set_yscale('log')
8212-
82138215
# If fill kwarg is set, it will be passed to the patch collection,
82148216
# overriding this
82158217
fill = (histtype == 'stepfilled')

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.