-
Notifications
You must be signed in to change notification settings - Fork 104
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
[feature request] geom_subplot #147
Comments
I have developed a new geometry library(dplyr)
library(purrr)
library(ggplot2)
# remotes::install_github("mkoohafkan/ggsubplot2")
library(ggsubplot2)
d1 = mtcars %>%
group_nest(gear, cyl) %>%
mutate(plot = map(data,
~ ggplot(.x, aes(x = mpg)) +
geom_density() +
theme_bw(base_size = 4)
))
ggplot(d1, aes(x = gear, y = cyl, plot = plot)) +
geom_subfig(width = 0.75, height = 0.75) |
Was hoping to use this for a project, but the map function seems to crash whenever I apply it to my data. The steps creating plots for each location may need work. |
@dlmolloy post your issue (with sample data) to the ggsubplot2 issues page and I'll see if I can help. This thread is generally about integrating or developing a subplot geom in ggforce. |
I have been away from the repo. Are you still interested in submitting this into ggforce? |
ggsubplot
has been deprecated for years, but tidyverse support for list columns and custom annotations inggplot2
make it pretty easy to mimic its functionality. However, there is some boilerplate logic that I could see fitting into a new geom, i.e.geom_subplot()
.First, some examples on how to embed plots in a plot:
And here's a more sophisticated example (link to blog plost with code).
I'm thinking a
geom_subplot()
could handle the last step of transforming a list of plots into custom annotations, replacing the final call topmap
and manual addition of the annotation list to the base plot in the above examples. In other words, the geom would take a dataframe with a list column containingggplot
objects and map them onto the "base" plot. This would provide maximum flexibility for users generating the suplots themselves and avoid a lot of the messy aesthetics that was inggsubplot
. The new geom would accept subplot locations, dimensions, and the subplots themselves (i.e.geom_subplot(aes(x, y, height, width, plot))
). At the same time, the new geom could provide helper arguments totheme
optionsannotation_custom
does not affect scales)height
andwidth
based on the extent of base plotI've been learning more about extending ggplot2 and would be interested in helping develop this functionality, but I don't think I have the necessary expertise to develop this on my own. I also would prefer to contribute to
ggforce
rather than try to maintain a separate package, sinceggforce
clearly has a well-developed underlying framework for developing new geoms.The text was updated successfully, but these errors were encountered: