Open ikashnitsky opened 4 years ago
This would be nearly impossible to add to the plot_grid()
function, for various technical reasons. Have you checked whether this works as expected with the patchwork package?
Yes, I expected that this might be very difficult.
{patchwork} doesn’t work in this particular case – {ggtern} redefines most of the {ggplot2} functions including %+%
. I wonder if it can be largely improved to work seamlessly with {ggplot2} and its extensions. Perhaps, something alike what {sf} does defining new coordinates. But that's clearly another story.
{patchwork} works with simple plots
library(tidyverse)
library(patchwork)
a <- mtcars %>%
mutate(cyl = cyl %>% factor) %>%
ggplot(aes(hp, wt, color = cyl, group = cyl))+
geom_point()+
stat_ellipse()+
theme(aspect.ratio = 1)
b <- a + facet_wrap(~cyl, ncol = 2)
a + b
#> Warning in as.numeric(w)/as.numeric(h): longer object length is not a
#> multiple of shorter object length
#> Warning in xList[i] <- valueList: number of items to replace is not a
#> multiple of replacement length
a + b + plot_layout(guides = "collect")
#> Warning in as.numeric(w)/as.numeric(h): longer object length is not a
#> multiple of shorter object length
#> Warning in as.numeric(w)/as.numeric(h): number of items to replace is not a
#> multiple of replacement length
Created on 2019-12-22 by the reprex package (v0.3.0)
A follow up on this SO question two years later, maybe a feature request if you agree on its usefulness.
Sometimes plots require fixed aspect ratio, e.g. ternary plots when the coordinate space triangle has to be regular. It would be very useful if
cowplot::plot_grid
can definerel_widths
orrel_height
automatically in order to scale and align the plots. Consider the example below:Created on 2019-12-21 by the reprex package (v0.3.0)