Skip to content
Merged
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
4 changes: 3 additions & 1 deletion lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5909,7 +5909,9 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
logbase = self.yaxis._scale.base

# Setting a minimum of 0 results in problems for log plots
if normed or weights is not None:
if np.min(bottom) > 0:
minimum = np.min(bottom)
elif normed or weights is not None:
# 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)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,30 @@ def test_hist_steplog():
plt.hist(data_big, 100, histtype='stepfilled', log=True, orientation='horizontal')


@image_comparison(baseline_images=['hist_step_log_bottom'],
remove_text=True, extensions=['png'])
def test_hist_step_log_bottom():
# check that bottom doesn't get overwritten by the 'minimum' on a
# log scale histogram (https://github.com/matplotlib/matplotlib/pull/4608)
np.random.seed(0)
data = np.random.standard_normal(2000)
fig = plt.figure()
ax = fig.add_subplot(111)
# normal hist (should clip minimum to 1/base)
ax.hist(data, bins=10, log=True, histtype='stepfilled',
alpha=0.5, color='b')
# manual bottom < 1/base (previously buggy, see #4608)
ax.hist(data, bins=10, log=True, histtype='stepfilled',
alpha=0.5, color='g', bottom=1e-2)
# manual bottom > 1/base
ax.hist(data, bins=10, log=True, histtype='stepfilled',
alpha=0.5, color='r', bottom=0.5)
# array bottom with some less than 1/base (should clip to 1/base)
ax.hist(data, bins=10, log=True, histtype='stepfilled',
alpha=0.5, color='y', bottom=np.arange(10))
ax.set_ylim(9e-3, 1e3)


def contour_dat():
x = np.linspace(-3, 5, 150)
y = np.linspace(-3, 5, 120)
Expand Down