question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Artificial gaps when plotting discrete data in distplot

See original GitHub issue

An issue that arises when plotting histograms of discrete data with Matplotlib seems to also come up in distplot as well. That is, there are often empty bins in the histogram that are entirely artifacts of the plot. See here for an example with Poisson data:

poisson data

Is there any way that distplot could try to detect this and adjust the bins automagically?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:3
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
mwaskomcommented, Aug 10, 2016

yes you need to do bins=np.arange(data.min(), data.max() + 1)

0reactions
fonnesbeckcommented, Jun 14, 2020

Thanks @mwaskom!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visualizing distributions of data - Seaborn - PyData |
A histogram is a bar plot where the axis representing the data variable is divided into a set of discrete bins and the...
Read more >
How to make discrete pcolor x-axis with no gaps between ...
You want to plot the data points at x = 1, 4, 9, 16, etc. separated by only one space? If so, the...
Read more >
Discrete Data Analysis with R: Visualization and Modeling ...
Find one or more examples of a graph or table that is a particularly bad use of display material to summarize and communicate...
Read more >
Chapter 4. Visualization with Matplotlib - O'Reilly
Matplotlib is a multiplatform data visualization library built on NumPy arrays, ... Our plot is looking nicer, but the spaces between the lines...
Read more >
What to do with missing values when plotting with seaborn?
seaborn.distplot(data['alcconsumption'].notnull(),hist=True,bins=100) ... I would definitely handle missing values before you plot your data.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found