mosaic icon indicating copy to clipboard operation
mosaic copied to clipboard

Add mosaic plots

Open domoritz opened this issue 2 years ago • 2 comments

Add https://en.m.wikipedia.org/wiki/Mosaic_plot to vgplot. Maybe we can do it already with bars or rectangles.

domoritz avatar Apr 17 '24 12:04 domoritz

It does seem fitting that a project named "Mosaic" should support mosaic plots :)

The DB query for this is easy (count aggregation, potentially with additional aggregates that could be assigned to color or opacity). The mark could determine a chart size (if not pre-specified) and layout could be computed easily on the client side, resulting in Plot rect marks for which we set the x1, x2, y1, and y2 channels.

I think the trickier part of shoe-horning this into Plot is the axes/labeling. Different rows/columns will have different spatial partitions. We could generate a compound mark that includes custom axisX and and axisY marks where we explicitly set the ticks values to align with the adjacent partitions and then use a tickFormat function that inversely maps quantitative values to category labels. However, I don't think we can support nested axes/labels this way, as the fx and fy scales for facets are always band scales and so we can not use quantitative axes here. Maybe a better alternative might be to use custom text marks instead?

jheer avatar Apr 17 '24 17:04 jheer

Aside +1 use case: this would be amazing! Would help me eliminate the slider from this demo: https://jaanli.github.io/american-community-survey/new-york-area/income-by-race

jaanli avatar Apr 17 '24 17:04 jaanli