Skip to content

Automatic number of bins for matplotlib histograms #4316

Description

@nayyarv

http://nbviewer.ipython.org/github/nayyarv/matplotlib/blob/master/examples/statistics/Automating%20Binwidth%20Choice%20for%20Histogram.ipynb

Long story short, plt.hist has poor default behaviour as I have to constantly play around with the number of bins to get a good idea of what I'm looking at. The bins=10 works ok for up to 1000 points, but has poor performance for anything more, and doesn't account for variability either

R doesn't suffer from these problems and provides methods for use with it's hist method. I would like to provide similar functionality for matplotlib, to at least provide some kind of good starting point, as histograms are very useful for initial data discovery.

The notebook above provides an explanation of the problem as well as some proposed alternatives. Use different datasets (type and size) to see the performance of the other alternatives suggested.

I've put together an implementation to add this new functionality, but am hesitant to make a pull request as I would like some feedback from a maintainer before doing so.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions