Skip to content

tickAnchor? #1495

Answered by mbostock
nobarany asked this question in Q&A
Apr 27, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

That’s a little tricky to do with a quantitative or temporal axis, as when using rectY and binX, because the axis doesn’t have a concept of an interval—it’s continuous.

Probably what you want here is to treat the temporal data as ordinal instead, which you can do using barY and groupX, in conjunction with the interval option. Here’s an example:

Plot.plot({
  x: {
    interval: 5, // this should match the rounding below!
    tickFormat: "" // don’t show a comma for years
  },
  marks: [
    Plot.barY(olympians, Plot.groupX({y: "count"}, {x: (d) => Math.floor(d.date_of_birth.getUTCFullYear() / 5) * 5}))
  ]
})

https://observablehq.com/@observablehq/plot-time-series-grouped-bars

That said, …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@nobarany
Comment options

Answer selected by Fil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants