plot icon indicating copy to clipboard operation
plot copied to clipboard

Add an example

Open Fil opened this issue 3 years ago • 3 comments

See this in the README: "TODO An example of assigning categorical colors in a scatterplot by descending count to maximize discriminability"

Fil avatar Jul 21 '22 05:07 Fil

I'm struggling a bit with this idea; it seems we would need two marks, one "fake" that does aggregation and sorts the color domain, and the unaggregated scatterplot. But then it's better to define the domain with d3.groupSort. https://observablehq.com/@observablehq/example-of-sorting-1003

In the meantime I suggest we remove the TODO (#1023).

Fil avatar Aug 07 '22 12:08 Fil

Here is a (contrived) demonstration of what I meant: https://observablehq.com/d/0fe77f38052f53f0

mbostock avatar Aug 07 '22 18:08 mbostock

OK! Would this simpler example work? Sorts the color domain by "rain, sun, fog, drizzle, snow".

Plot.plot({
  width,
  color: { legend: true },
  marks: [
    Plot.link(weather, {
      x: "date",
      y1: "temp_min",
      y2: "temp_max",
      stroke: "weather",
      sort: { color: "stroke", reduce: "count", reverse: true }
    })
  ]
})

https://observablehq.com/@observablehq/example-of-sorting-1003

Fil avatar Aug 08 '22 13:08 Fil

I published my notebook above. I think it’s good enough and it has accompanying explanatory text.

mbostock avatar Nov 27 '22 18:11 mbostock