I’m making a figure with several density scatterplots; I have the following data and the following figure.
Data_Frame <- data.frame(Column_1 = rep(LETTERS[1:4], each = 100), Column_2 = rnorm(400), Column_3 = rnorm(400))
Data_by_Column_1 <- split(Data_Frame, Data_Frame$Column_1)
All_Plots <- lapply((seq_len(length(Data_by_Column_1) + 1)), function (x) {
if (x == 1) {
ggplot() +
geom_text(aes(x = 0, y = 0, label = "Figure Title"), size = 5) +
theme_void()
} else if (x > 1) {
ggplot(data = Data_by_Column_1[[(x - 1)]], mapping = aes(x = Column_2, y = Column_3)) +
geom_pointdensity() +
theme_bw() +
scale_color_viridis() +
geom_hline(yintercept = 0, linetype = "dashed", color = "red", size = 1.25) +
geom_vline(xintercept = 0, linetype = "dashed", color = "green", size = 1.25)
}
})
Arranged_Plots <- do.call("grid.arrange", c(All_Plots, list(layout_matrix = matrix(c(1, 1, 2, 3, 4, 5), byrow = TRUE, ncol = 2), heights = c(0.25, 1, 1))))
Arranged_Plots
I want to add a sixth plot at the bottom that’s totally blank (like the first plot in this figure that just contains the title) except for a legend containing information about the two reference lines (the red horizontal dashed lines and the green vertical dashed lines).
How can I make this last plot?