exaexa / scattermore

very fast scatterplots for R
https://exaexa.github.io/scattermore/
GNU General Public License v3.0
243 stars 7 forks source link

Support for faceting in geom_scattermost()? #8

Open garciamikep opened 3 years ago

garciamikep commented 3 years ago

Great package, thank you so much! This has been a lifesaver in improving performance of some heavy plots.

I'm wondering if there is any possibility of support for faceting using geom_scattermost()? I need the speed and memory performance of scattermost, so adding a facet_wrap() layer to geom_scattermore() isn't really an option. I've hacked something together by creating a list of the scattermost subplots and using patchwork::wrap_plots() to stitch them together. However, this leads to some challenges getting theming applied consistently, particularly axis limits.

I also realize that geom_scattermost() is intended to be minimal, so not sure if this is beyond the scope of what's intended for this package.

exaexa commented 3 years ago

Hello! unfortunately that's not very easily possible -- by definition, if you want ggplot to separate your data into the facets, the data needs to inevitably pass through ggplot, and the scattermost shortcut won't work.

There might be some chance of giving a list of pre-rendered bitmap geoms/grobs directly to ggplot; which it might be able to facet correctly, but we'd need a serious ggplot expert for this.

Another solution (perhaps much better) could be some option to "plot a scattermost to a specific facet", in turn you would

I'll try to have a look into how to do that.

garciamikep commented 3 years ago

Thank you for the quick response! I had a hunch it wouldn't be straightforward, as geom_scattermost works by intentionally bypassing ggplot machinery. While it would be slick to simply add + facet_wrap(~facet_var) to your plot code, something like what you suggest would be great (and a great improvement over what I'm currently doing).

exaexa commented 2 years ago

@garciamikep, we might revive this issue pretty soon... Any chance you have some new pointers on how to do this faceting thing correctly with ggplot? (maybe we should open a "question" issue in ggplot repo, because the documentation really doesn't say much about how to do custom facets like this)

garciamikep commented 2 years ago

That's great! Unfortunately I don't have any updates beyond the workaround I mentioned above. I'm far from a ggplot expert, but very curious to tag along/contribute if possible.

By "correctly with ggplot" do you mean the pre-rendered geom/grob approach you described above?