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

Axes.hist: use bottom for minimum if log and histtype='step...' #4608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 10, 2015
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 4 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 24 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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.