我使用facet_grid在我的绘图中创建了一个标题,这个标题被一个白色背景的黑色方框所包围。我想知道如何增加这个带有标题的盒子和我的情节的上边缘之间的空间。下面我展示了一个类似的情节,我给了一个假的代码来玩。
library(ggplot2)
library(cowplot)
library(ggpubr)
theme_set(theme_cowplot())
df1 <- data.frame(x = 1:12, y = (1:12)^2, grp=c('A', 'B', 'C'), depth=c("5m","5m","5m","5m"))
p1 <- ggplot(df1, aes(x, y, color=grp)) + geom_point() + facet_grid(.~depth) +
theme(strip.background = element_rect(colour = "black", fill = "white", size = 1.5, linetype = "solid"))
p1
有人知道怎么做吗?一个增加面框和情节上边缘之间的空间的替代方法也可以是不使用 facet_grid
. 但是,我找不到一个替代的方法来绘制一个周围有黑框的标题。如果你有其他方法,而不是使用 facet_grid
是欢迎的。