TidierOrg / TidierPlots.jl

Tidier data visualization in Julia, modeled after the ggplot2 R package.
MIT License
196 stars 7 forks source link

Patchwork extension #95

Closed cnrrobertson closed 2 months ago

cnrrobertson commented 2 months ago

This PR extends the patchwork functionality from #61 for arbitrary numbers of GGPlots and GGPlotGrids. It adds tests and docs for these as well.

Although it's all working pretty well, there does seem to be one hiccup that I'm not sure how to overcome. In summary, we can do more than two operations with + simultaneously but not with | or /. i.e. plot + plot + plot gives 3 side by side plots of equal width whereas plot | plot | plot has two of 1/4 width and one of 1/2. This is effectively because the + operator works with variable number of arguments while the |, / process one by one. I'm not sure how to get around this as it has to do with how the operator expression is parsed.

You can explore this by looking at the difference between Meta.parse("1 + 2 + 3").args and Meta.parse("1 | 2 | 3").args.

rdboyes commented 2 months ago

I'm not 100% sure how to solve the problem, but maybe the answer is to manually set the colsizes to be equal in GridLayout's options? See here for accepted options: https://docs.makie.org/stable/explanations/specapi/#advanced_spec_layouting

rdboyes commented 2 months ago

The other thing - at least for /, this might be expected behaviour? I would have to go back and use R's patchwork, but a/b/c resulting in two quarter-height plots and one half-height plot feels correct to me. We could implement plot_layout in order to allow users to change that default once the configuration of the plots is correct

cnrrobertson commented 2 months ago

Sorry, had some testing imports leftover that broke the Github Action. Should be ready now.

rdboyes commented 2 months ago

I’ll merge this on the weekend - apparently there are merge conflicts and I don’t want to try to resolve them on my phone!