Closed rdboyes closed 1 month ago
I love patchwork and currently use it for an R package. I make use of the plot_layout()
functionality to control the relative proportions of the plots.
If/when this is implemented, I will look forward to porting over my R package.
This is working as of the latest version:
using TidierPlots, DataFrames
df = DataFrame(x = [1, 2, 3], y = [2, 3, 4], z = [3, 4, 5])
p1 = ggplot(df) + geom_point(@aes(x, y))
p2 = ggplot(df) + geom_point(@aes(x, z))
p1 + p2
p1 / p2
Still need to implement plot_layout()
though!
Do we also support p1 | p2
for side by side plots?
We don’t, but we can! I never realized that was an operator in patchwork to be honest - is it exactly the same as + (which also puts plots side by side)?
bar operator supported as of https://github.com/TidierOrg/TidierPlots.jl/commit/1473747a60d6afe6fe403b136099e732137a319f
Yes, same functionality as +
Been trying this out in 0.7.3
and really enjoying the simplicity of creating layouts with it. Would it be possible to extend this to multiple plots? i.e. plot1 | plot2 | plot3
?
Currently, it is missing the function |(GGPlotGrid, GGPlot)
to be able to combine grid objects with individual plots.
That's the plan! Just need to add some more functions and I haven't gotten around to it yet
If you want to give it a go, the GGPlotGrid struct
contains a vector of the plots for exactly this reason (i.e. |(GGPlotGrid, GGPlot)
should extract the plots from GGPlotGrid, append the GGPlot to that list, and return a new GGPlotGrid
With #95, we could now have:
t = ggplot(penguins) +
geom_point(@aes(x = bill_length_mm, y = bill_depth_mm));
((t + t + t) | (t / t)) / t
and get
Working on plot_layout
in #99. So far, functionality for rows, columns, widths, and heights are in.
t = ggplot(penguins) +
geom_point(@aes(x = bill_length_mm, y = bill_depth_mm));
t + t + t + plot_layout(;nrow=2, heights=[3,1], widths=[1,2])
and its working with combination of previous grids and plots as well:
grid = (t + t + t) / t
grid + t + plot_layout(;nrow=2, heights=[1,2])
This is amazing progress @cnrrobertson - I see the PR is still marked as draft, just let me know when you think its ready to be merged
Makie's grid layout system should allow implementation of a
patchwork
-like syntax for simple layouts. Initial implementation should include:Base.:+(plot1::GGPlot, plot2::GGPlot)
- returns a plot with plot1 and plot2 side by sideBase.:/(plot1::GGPlot, plot2::GGPlot)
- returns a plot with plot1 above plot2plot_layout
to modify relative proportions