Skip to content
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

dense interval for line and area #792

Merged
merged 6 commits into from
Mar 1, 2022
Merged

dense interval for line and area #792

merged 6 commits into from
Mar 1, 2022

Conversation

mbostock
Copy link
Member

Fixes #597. Fixes #351.

With the default reduce = sum:

Screen Shot 2022-02-28 at 1 41 13 PM

With reduce = median:

Screen Shot 2022-02-28 at 1 41 28 PM

@mbostock mbostock requested a review from Fil February 28, 2022 21:41
@mbostock mbostock force-pushed the mbostock/dense-interval branch from 299fa76 to cb84431 Compare February 28, 2022 21:45
@mbostock
Copy link
Member Author

mbostock commented Feb 28, 2022

In terms of the example in #351 (comment), I don’t think I would use the new interval option introduced by this PR, and would instead add filter = null to generate dense bins in the first bin transform.

Screen Shot 2022-02-28 at 1 56 05 PM

Plot.plot({
  y: {
    axis: "right",
  },
  facet: {
    data: penguins,
    y: "species",
    marginLeft: 80,
  },
  marks: [
    Plot.areaY(
      penguins,
      Plot.stackY(
        Plot.binX(
          { y: "count", filter: null },
          { x: "body_mass_g", thresholds: 20, fill: "sex", fillOpacity: 0.2 }
        )
      )
    ),
    Plot.ruleY([0]),
    Plot.lineY(
      penguins,
      Plot.stackY2(
        Plot.binX(
          { y: "count", filter: null },
          { x: "body_mass_g", thresholds: 20, stroke: "sex", marker: "circle" }
        )
      )
    ),
  ],
})

@Fil
Copy link
Contributor

Fil commented Mar 1, 2022

Could we change the default reducer to "first"? "sum" only works with a quantitative y, whereas "first" (or "mode", but it's slower and not that better) would also work with an ordinal y.

@mbostock
Copy link
Member Author

mbostock commented Mar 1, 2022

Could we change the default reducer to "first"?

Okay, done. This means you’ll see gaps by default, which is probably a good thing… and I suppose adding reduce = sum isn’t too hard to remember?

@mbostock mbostock merged commit 2632b99 into main Mar 1, 2022
@mbostock mbostock deleted the mbostock/dense-interval branch March 1, 2022 17:03
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.

Interval (or series?) transform for line and area Add a "full series" option to the stack transforms
2 participants