Reputation: 2356
I've made a series of plots that I want to print on the same page.
The main plot, dotplot_summary
, is a summary of the plots in dotplots_indiv <- list(p1, p2, p3)
.
I'd like the first plot to be the same size as the plots on the second row, but I can't figure out how.
My reprex is here: https://pastebin.com/wjhmSFiB
p_indiv <- wrap_plots(dotplots_indiv)
patchwork <- (dotplot/p_indiv) + plot_layout(nrow = 2, widths = c(1, 3)
I was thinking of adding plot spacers, but the number of plots that can fit in the lower row is variable.
Thanks.
Upvotes: 2
Views: 1476
Reputation: 39605
I was not able to reproduce the issue with the data you shared as it is giving errors but I sketched an example. You can use the layout
option in wrap_plots()
defining a matrix style like this (I have used iris
data):
library(patchwork)
library(ggplot2)
#Plot 1
G1 <- ggplot(iris,aes(x=Sepal.Length,y=Sepal.Width))+
geom_point()
#Plot 2
G2 <- ggplot(iris,aes(y=Sepal.Length,x=Sepal.Width))+
geom_point()
G3 <- ggplot(iris,aes(y=Petal.Width,x=Sepal.Width))+
geom_point()
G4 <- ggplot(iris,aes(y=Petal.Length,x=Petal.Width))+
geom_point()
#Wrap
#Layout
layout <- '
#A#
BCD
'
#Plot
wrap_plots(A = G1, B = G1,C=G2,D=G3, design = layout)
Output:
All plots will keep same dimension, rather than this:
Which follows a code structure similar to the one you shared.
Upvotes: 1