Skip to content

bin interval - #735

Merged
mbostock merged 3 commits into
mainfrom
mbostock/bin-interval
Feb 3, 2022
Merged

mbostock merged 3 commits into
mainfrom
mbostock/bin-interval

Conversation

@mbostock

@mbostock mbostock commented Feb 3, 2022

Copy link
Copy Markdown
Member

This…

  • Allows numeric intervals (such as integers) to be specified as the interval option, while avoiding ambiguity with the thresholds option where a number represents the desired number of thresholds.
  • When thresholds is specified as an numeric interval (typically indirectly by using the interval option, but also if thresholds is specified explicitly as an interval object), extends the domain to cover the first and last interval automatically. This avoids zero-width bins as seen in When explicit bin thresholds are specified, but no domain is specified, the last bin is dropped #733, and we already do this for temporal data.

Fixes #734. For example, with hourly data:

Screen Shot 2022-02-02 at 7 40 43 PM

Plot.plot({
  marks: [
    Plot.rectY(timestamps, Plot.binX({y: "count"}, {x: d => d.timestamp.getUTCHours(), interval: 1}))
  ]
})

@mbostock
mbostock requested a review from Fil February 3, 2022 03:45
@mbostock
mbostock force-pushed the mbostock/bin-interval branch from d3310ac to 8f25ee0 Compare February 3, 2022 03:49
@mbostock
mbostock force-pushed the mbostock/bin-interval branch from 8f25ee0 to 5bd672b Compare February 3, 2022 03:50

@Fil Fil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

@mbostock
mbostock merged commit 5d06b6f into main Feb 3, 2022
@mbostock
mbostock deleted the mbostock/bin-interval branch February 3, 2022 19:09
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

Successfully merging this pull request may close these issues.

Intervals for binning

2 participants