Skip to content

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

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
cnowzohour opened this issue May 12, 2017 · 3 comments
Closed

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

cnowzohour opened this issue May 12, 2017 · 3 comments

Comments

@cnowzohour
Copy link

I am creating very fine-grained histograms of timestamps and discovered that when the bin size is too small the plot just silently omits parts of the data. In the example below I create hourly timestamps for one day and then plot a histogram of bin size 10s. With this bin size only the hours 12am to 1pm get displayed. When increasing the bin size to 20s, all 25 timestamps are plotted.

I am using R 3.3.3 and plotly 4.6.0.

library(plotly)

bin.size.s <- 10

startPOSIX <- as.POSIXct("2017-05-12 00:00:00")
endPOSIX <- as.POSIXct("2017-05-13 00:00:00")
ts <- seq(as.numeric(startPOSIX, origin = "1970-01-01"), as.numeric(endPOSIX, origin = "1970-01-01"), by = 3600)

bins <- list(
  start = startPOSIX,
  end = endPOSIX,
  size = bin.size.s * 1000
)

print(
  plot_ly() %>%
    add_histogram(x = as.POSIXct(ts, origin = "1970-01-01"), autobinx = FALSE, xbins = bins)
)
@cpsievert
Copy link
Collaborator

Hmm, I see this with the most recent version 4.6.0.9000

screen shot 2017-05-12 at 11 10 55 am

Is that not what you expect?

@cnowzohour
Copy link
Author

No: there are 25 timestamps in the dataset, but only 14 are displayed. You can check this by increasing bin.size.s to 20 or by hist(as.POSIXct(ts, origin = "1970-01-01"), breaks = "mins").

@cnowzohour
Copy link
Author

I realized that this issue is not related to timestamps, but occurs generally when the bin size is too small. It seems to be an issue in plotly.js:

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

vs

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

I'll create an issue there.

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

No branches or pull requests

2 participants