Skip to content

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

Closed
@cnowzohour

Description

@cnowzohour

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)
)

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