I want fig1
to span over three columns, and I have three versions of fig4
that need to be in row 2, in each column.
set.seed(111)
f1 <- data.frame(forest.type = rep(c("A","B","C","D"), times = 36 ),
sp.type = rep(c("X","Y","Z"), times = 48),
time.type = rep(c(1:12), each = 12),
number.type = rnorm(144))
fig1 <- ggplot(aes(x = time.type, y = number.type), data = f1) +
geom_point() +
theme_classic() + facet_grid(forest.type ~ sp.type, scales="free") +
theme(legend.position = "none") + theme(aspect.ratio = 10/20) +
ggtitle("These wont stretch across the three columns")
fig4 <- ggplot(aes(x = time.type, y = number.type), data = f1) +
geom_point() +
theme_classic() +
theme(legend.position = "none") + theme(aspect.ratio = 7/5) +
ggtitle("All this goes in \nrow 2")
fig1 <- fig1 + theme(plot.margin=unit(c(0,0,0,0),"cm"))
fig4 <- fig4 + theme(plot.margin=unit(c(0,0,-10,1),"cm"))
I tried various versions of the plot.margin
but I am not able to get fig 1 to span all three columns. Also, I only get this figure when I use zoom
in. When I try to save it to the plot dimensions I need (21 cm height and 16.5 width), the figure get smushed. In the "Zoom" in version the axis text size is too tiny and doesn't match up with the other figures I'm printing for the manuscript.
EDIT: I tried cowplot
as suggested. However, I face similar problems..
set.seed(111)
f1 <- data.frame(forest.type = rep(c("A","B","C","D"), times = 36 ),
sp.type = rep(c("X","Y","Z"), times = 48),
time.type = rep(c(1:12), each = 12),
number.type = rnorm(144))
fig1 <- ggplot(aes(x = time.type, y = number.type), data = f1) +
geom_point() +
theme_classic() + facet_grid(forest.type ~ sp.type, scales="free") +
theme(legend.position = "none") + theme(aspect.ratio = 10/20) +
ggtitle("These wont stretch across the three columns")
fig1 <- fig1 + theme(plot.margin=unit(c(0,0,0,0),"cm"))
fig4 <- fig4 + theme(plot.margin=unit(c(0,0,0,0),"cm"))
library("cowplot")
ggdraw() +
draw_plot(fig1, x = 0, y = 0.5, width = 1, height = 0.5) +
draw_plot(fig4, x = 0, y = 0, width = 0.3, height = .5) +
draw_plot(fig4, x = 0.3, y = 0, width = 0.3, height = .5) +
draw_plot(fig4, x = 0.6, y = 0, width = 0.3, height = 0.5) +
draw_plot_label(label = c("A", "B", "C","D"), size = 15,
x = c(0, 0, 0.3, 0.6), y = c(0.5, 0, 0, 0))