8000 Remove extra stickies in barstacked histogram. by anntzer · Pull Request #18464 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Remove extra stickies in barstacked histogram. #18464

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 1 commit into from
Sep 13, 2020
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
14 changes: 10 additions & 4 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6660,13 +6660,19 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
height = m - bottom
else:
height = m
patch = _barfunc(bins[:-1]+boffset, height, width,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(this is actually a BarCollection object, not a Patch...)

align='center', log=log,
color=c, **{bottom_kwarg: bottom})
patches.append(patch)
bars = _barfunc(bins[:-1]+boffset, height, width,
align='center', log=log,
color=c, **{bottom_kwarg: bottom})
patches.append(bars)
if stacked:
bottom[:] = m
boffset += dw
# Remove stickies from all bars but the lowest ones, as otherwise
# margin expansion would be unable to cross the stickies in the
# middle of the bars.
for bars in patches[1:]:
for patch in bars:
patch.sticky_edges.x[:] = patch.sticky_edges.y[:] = []

elif histtype.startswith('step'):
# these define the perimeter of the polygon
Expand Down
10 changes: 10 additions & 0 deletions lib/matplotlib/tests/test_axes.py
4E37
Original file line number Diff line number Diff line change
Expand Up @@ -1679,6 +1679,16 @@ def test_hist_log_2(fig_test, fig_ref):
ax.hist(1, 1, log=True, histtype=histtype)


def test_hist_log_barstacked():
fig, axs = plt.subplots(2)
axs[0].hist([[0], [0, 1]], 2, histtype="barstacked")
axs[0].set_yscale("log")
axs[1].hist([0, 0, 1], 2, histtype="barstacked")
axs[1].set_yscale("log")
fig.canvas.draw()
assert axs[0].get_ylim() == axs[1].get_ylim()


@image_comparison(['hist_bar_empty.png'], remove_text=True)
def test_hist_bar_empty():
# From #3886: creating hist from empty dataset raises ValueError
Expand Down
0