Skip to content

Binning temporal data using the built-in _hours_ interval forces interval boundaries to start at midnight #2452

Description

@mwaibel-go

Consider the following plot invocation. Every hour there’s an event and I’m trying to bin them in intervals of 11 hours each.

Plot.plot({
  color: { legend: true, transform: null },
  marks: [
    Plot.barY(
      Array.from({length: 48}, (_, i) => (new Date(2026, 7, 1 + Math.floor(i / 24), i%24))),
      Plot.binY({fill: 'count'}, {y: { interval: '11 hours'}})
    )
  ]
})
Image

I expected each bin to be the same size (maybe expect the very last one). Instead each day is individually divided into two bins of size 11 hours and one bin of size 2 hours.

The same happens for every interval of which 24 hours isn’t an integer multiple (i.e., 5, 7, 9, …).

This might be related to #2450

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn’t working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions