Skip to content

Feature request: show bars in plt.hist #12874

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

Closed
rosgori opened this issue Nov 24, 2018 · 5 comments
Closed

Feature request: show bars in plt.hist #12874

rosgori opened this issue Nov 24, 2018 · 5 comments
Labels
status: closed as inactive Issues closed by the "Stale" Github Action. Please comment on any you think should still be open. status: inactive Marked by the “Stale” Github Action topic: hist topic: rcparams

Comments

@rosgori
Copy link

rosgori commented Nov 24, 2018

Feature request

Summary

With the new style of plotting (after version 1.5), you cannot distinguish the bars on plt.hist. Take for example the old way:

import matplotlib.pyplot as plt
import random

l_n = []
for _ in range(2000):
    l_n.append(random.betavariate(5, 25))

with plt.style.context('classic'):
    plt.hist(l_n, bins=20)
    plt.show()

Unfortunately, I cannot upload images. Nevertheless, you can see the bars. Now, this:

plt.hist(l_n, bins=20)
plt.show()

You only see the silhouette of the histogram, not the bars. An easy way to solve this:

plt.hist(l_n, bins=20, edgecolor='w')
plt.show()

edgecolor='w' would be the default option (I would prefer white because it looks good with all the styles). What do you think?

By the way, if you want to compare with other software, I think all of them show bars. And a quick search shows...

Matplotlib version

  • Operating system: Ubuntu 16.04.5 LTS
  • Matplotlib version: 3.0.1
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.6.6
  • Jupyter version (if applicable): 7.1.1
  • Other libraries:
  • How I installed matplotlib: conda
@jklymak
Copy link
Member

jklymak commented Nov 24, 2018

plt.hist(l_n, bins=20, edgecolor='w') works fine, so are you asking that this be the default? I'd not particularly support that. On the other hand maybe a hist.edgecolor rcparam could be considered (I didn't see one, though you can patch.force_edgecolor.

@anntzer
Copy link
Contributor

anntzer commented Nov 24, 2018

Discussed #12493 as well.

@rosgori
Copy link
Author

rosgori commented Nov 25, 2018

Yes, I agree with you that edgecolor='w' might not be the best option.

Besides, I didn't know that a change in these two lines

#patch.edgecolor : black ## if forced, or patch is not filled
#patch.force_edgecolor : False ## True to always use edgecolor

achieves what I am looking for.

So... do you think this feature should be included in matplotlib (either with a new parameter hist.edgecolor or a change in patch.force_edgecolor or with another solution)?

@timhoffm
Copy link
Member

I agree that bars in histograms should be visually separate. The current default behavior is not good.

A hard coded default edgecolor='w' can break styles.

Rcparams patch.edgecolor and patch.force_edgecolor are too global in their scope.

Therefore a hist.edgecolor rcparam is the reasonable way to go.

Copy link

github-actions bot commented Nov 3, 2023

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Nov 3, 2023
@github-actions github-actions bot added the status: closed as inactive Issues closed by the "Stale" Github Action. Please comment on any you think should still be open. label Dec 4, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: closed as inactive Issues closed by the "Stale" Github Action. Please comment on any you think should still be open. status: inactive Marked by the “Stale” Github Action topic: hist topic: rcparams
Projects
None yet
Development

No branches or pull requests

5 participants