Skip to content
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

Bug: histogram silently ignores data, when bin size is too small #1682

Closed
cnowzohour opened this issue May 12, 2017 · 3 comments
Closed

Bug: histogram silently ignores data, when bin size is too small #1682

cnowzohour opened this issue May 12, 2017 · 3 comments
Labels
bug something broken

Comments

@cnowzohour
Copy link

When plotting histograms with very fine grained bins, some data will be ignored. See:

https://codepen.io/cnowzohour/pen/qmYmoM

vs

https://codepen.io/cnowzohour/pen/vmjmjM

Both histograms should show 10 bars, but the second one only shows 5 - the only difference being the bin size of 0.005 vs 0.001.

I realized this when visualizing timestamps over one day with a bin size of 10 seconds:

plotly/plotly.R#1001

@etpinard
Copy link
Contributor

Thanks for the report. Looks like this hard-coded 5000 bin limit is the culprit. For example, bumping that number to 50000 yields:

image

as desired.

We should come up with a better upper bound. Maybe something like x.length / bins.size?

@etpinard etpinard added the bug something broken label May 12, 2017
@cnowzohour
Copy link
Author

Yeah I guess 5000 can be a bit conservative in cases when the data is sparse and only a small subset of the bins are actually drawn. Also, it would be great if it was somehow visible if this limit is exceeded (and data is omitted). Maybe via a big last bin, containing all the remaining data?

@etpinard
Copy link
Contributor

etpinard commented May 16, 2017

Update: changing the while clause from

while(i < binend && pos.length < 5000) {}

to

while(i < binend && pos.length < (pos0.length / bins.size)) {}

breaks some of our tests. We'll have to dig deeper to find a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

No branches or pull requests

2 participants