Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functionality from patchwork #61

Closed
3 tasks done
rdboyes opened this issue Feb 28, 2024 · 11 comments
Closed
3 tasks done

Functionality from patchwork #61

rdboyes opened this issue Feb 28, 2024 · 11 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@rdboyes
Copy link
Member

rdboyes commented Feb 28, 2024

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 side
  • Base.:/(plot1::GGPlot, plot2::GGPlot) - returns a plot with plot1 above plot2
  • plot_layout to modify relative proportions
@rdboyes rdboyes added the enhancement New feature or request label Feb 28, 2024
@kdpsingh
Copy link
Member

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.

@rdboyes
Copy link
Member Author

rdboyes commented Mar 5, 2024

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

download

p1 / p2

download

Still need to implement plot_layout() though!

@rdboyes rdboyes closed this as completed Mar 5, 2024
@rdboyes rdboyes reopened this Mar 5, 2024
@kdpsingh
Copy link
Member

kdpsingh commented Mar 5, 2024

Do we also support p1 | p2 for side by side plots?

@rdboyes
Copy link
Member Author

rdboyes commented Mar 5, 2024

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)?

@rdboyes
Copy link
Member Author

rdboyes commented Mar 5, 2024

bar operator supported as of 1473747

@kdpsingh
Copy link
Member

kdpsingh commented Mar 6, 2024

Yes, same functionality as +

@rdboyes rdboyes added this to the v0.8.0 milestone Apr 10, 2024
@rdboyes rdboyes mentioned this issue Apr 15, 2024
8 tasks
@cnrrobertson
Copy link
Contributor

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.

@rdboyes
Copy link
Member Author

rdboyes commented Apr 25, 2024

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

@cnrrobertson
Copy link
Contributor

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
test_patch

@cnrrobertson
Copy link
Contributor

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])

tvar

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])

tvar2

@rdboyes
Copy link
Member Author

rdboyes commented Apr 30, 2024

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

@rdboyes rdboyes closed this as completed May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants