Skip to content

Conversation

@mbostock
Copy link
Member

@mbostock mbostock commented Jun 16, 2022

Screen Shot 2022-06-15 at 11 35 39 PM

Plot.plot({
  inset: 20,
  marks: [
    Plot.density(faithful, {x: "waiting", y: "eruptions", stroke: "steelblue", strokeWidth: 0.25}),
    Plot.density(faithful, {x: "waiting", y: "eruptions", thresholds: 4, stroke: "steelblue"}),
    Plot.dot(faithful, {x: "waiting", y: "eruptions", fill: "currentColor", r: 1.5})
  ]
})

TODO

  • group by z (or fill or stroke)

Open questions:

  • Should this be called contour instead of density (to match ggplot2)?
  • What if you want non-density contours, like for a topographic map or a continuous function?
  • What if you want one-dimensional density (KDE)? Is that a transform?
  • Should there be a legend or continuous color encoding for density contours?

@mbostock mbostock requested a review from Fil June 16, 2022 06:36
@Fil Fil mentioned this pull request Jun 22, 2022
7 tasks
@Fil
Copy link
Contributor

Fil commented Jun 22, 2022

A few more features in #948.

Should this be called contour instead of density (to match ggplot2)?

I agree that density or density contours is a better name than "contours" because we might want to create other types of contours.

one-dimensional density (KDE)? Is that a transform?

yes, very similar to 1-d binning

a legend or continuous color encoding for density contours?

I don't think it's possible to make a readable "density level" legend (points per pixel square?)

@Fil
Copy link
Contributor

Fil commented Jun 24, 2022

superseded by #948

@Fil Fil closed this Jun 24, 2022
@mbostock mbostock reopened this Jun 24, 2022
@mbostock mbostock force-pushed the mbostock/density-contours branch from 383bba2 to 8286adb Compare June 24, 2022 15:47
@mbostock mbostock force-pushed the mbostock/density-contours branch from 8286adb to 22e478c Compare June 24, 2022 15:51
* density contours as an initializer: first pass

* density by z, carrying styles and channels (no reducer, only "first")

* fill: "density"

* density weight

* consistent thresholds across facets and series

note: we have to go around this bug in d3-contour: d3/d3-contour#57

* allow initializer composition; move initializer to the class; clean up

* density weight example

* error if x or y is undefined

(in the future we might route those to 1-dimensional transforms—KDE)

* document

* reduce img

* * don't apply the scales if we are already in pixel space (e.g. when composing with the hexbin transform)
* avoids a crash when there is no contour

* 1d density contours with frameAnchor

* adopt d3@7.4.5 for https://github.com/d3/d3-contour/releases/tag/v3.0.2

(not entirely sure if it's good practice to have all the yarn.lock changes in the PR, beyond those that are relevant)

* replace example image

* mike’s edits

* fix image dimensions

* isDensity

* distinct

* tweak tests

Co-authored-by: Mike Bostock <mbostock@gmail.com>
@mbostock mbostock merged commit b8eb6c1 into main Jun 24, 2022
@mbostock mbostock deleted the mbostock/density-contours branch June 24, 2022 20:47
@mbostock mbostock mentioned this pull request Jul 3, 2022
@Fil Fil mentioned this pull request Apr 19, 2023
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.

3 participants