observablehq / plot

A concise API for exploratory data visualization implementing a layered grammar of graphics
https://observablehq.com/plot/
ISC License
4.47k stars 182 forks source link

Hexbin is not fixed to projected coordinates #1257

Closed mythmon closed 1 year ago

mythmon commented 1 year ago

https://observablehq.com/d/9adf8455382f0bf6

On the map in the above notebook, I've plotted eBird observations using Plot.geo and Plot.hexbin. When adjusting the translation of the projection, the hex bins stay fixed in screen space, instead of moving with the projection. This causes the binned representation to change, sometimes drastically. The effect is more noticeable when moving the Y slider.

I'm not sure that this is wrong, either from a Plot point of view or from a cartography point of view. However, it did make the person working with me, who is much more versed in birding and cartography than I am, react in horror. It seems to me at least surprising, and probably undesirable. The binning isn't wrong in either case, but I wouldn't expect it to change at all as I pan.

Translated down. Note the single bold hexTranslated up. Note the three bold hexes
mbostock commented 1 year ago

This is the intended behavior. The hexagons are positioned (and sized) in screen space, so the hexagons stay in the same position even as the x and y scales (or equivalent the projection) changes. Since the dots are moving but the hexagons stay in the same place, the association of dots and hexagons changes.