Add `ggdeck()` for overlaying two on more plots
The overlayed plots should have their drawing areas perfectly aligned and should be able to share one or both axis.
This would probably provide a more elegant solution than implementing a traditional 'secondary Y-axis' feature (see #1161).
The use case for this issue comes up quite regularly on my end (almost weekly if not daily) when using lets-plot. Is this something where I could help out as a contributor? If so, where would I start?
Hi, @nsiicm0,
The good news first: in the recent Lets-Plot v4.8.0, we took a step closer by adding support for optional legend sharing in gggrid() - this would be the default behavior in ggdeck(). Both gggrid() and the proposed ggdeck() are "composite figures" but with different layout approaches.
Also not bad news - several building blocks already exist:
- Axis limit sharing between subplots is implemented in
gggrid()viasharex/shareyparameters, which can likely be adapted forggdeck() - Plot inner area alignment (i.e., "geom" bounds alignment) is already implemented in the
gggridlayout via thealignparameter and can be reused in some form
Remaining challenges:
- Shared axis rendering: Axes shouldn't render on top of each other or overlap. Currently this can only be achieved by manual customization of each plot in the deck
- Transparency: Additional plots should be visually transparent (only the 'base' plot should have a background)
- Synchronized interactions: Panning and zooming should happen synchronously across all plots in the deck (this is also planned for
gggrid) - Tooltips: Need to work across all overlaid plots
The task is definitely challenging, but perhaps not everything needs to be in place for an MVP.
Where to start: Here are some useful references to explore:
Python API: gggrid layout configuration Kotlin: Grid layout object configuration Kotlin: Building composite figures
Let me know if you have further questions about the codebase or on the approach generally.