我有同樣的問題,並與下面的解決方案,這是一個有點不同想出了:
裝載R封裝
library(ggplot2)
library(grid)
library(gridExtra)
示例數據
a <- 1:20
b <- sample(a, 20)
c <- sample(b, 20)
d <- sample(c, 20)
創建一個數據幀
mydata <- data.frame(a, b, c, d)
創建示例曲線
myplot1 <- ggplot(mydata, aes(x=a, y=b)) + geom_point()
myplot2 <- ggplot(mydata, aes(x=b, y=c)) + geom_point()
myplot3 <- ggplot(mydata, aes(x=c, y=d)) + geom_point()
myplot4 <- ggplot(mydata, aes(x=d, y=a)) + geom_point()
組邊角標籤
myplot1 <- arrangeGrob(myplot1, top = textGrob("A", x = unit(0, "npc")
, y = unit(1, "npc"), just=c("left","top"),
gp=gpar(col="black", fontsize=18, fontfamily="Times Roman")))
myplot2 <- arrangeGrob(myplot2, top = textGrob("B", x = unit(0, "npc")
, y = unit(1, "npc"), just=c("left","top"),
gp=gpar(col="black", fontsize=18, fontfamily="Times Roman")))
myplot3 <- arrangeGrob(myplot3, top = textGrob("C", x = unit(0, "npc")
, y = unit(1, "npc"), just=c("left","top"),
gp=gpar(col="black", fontsize=18, fontfamily="Times Roman")))
myplot4 <- arrangeGrob(myplot4, top = textGrob("D", x = unit(0, "npc")
, y = unit(1, "npc"), just=c("left","top"),
gp=gpar(col="black", fontsize=18, fontfamily="Times Roman")))
一個頁面上標出所有地塊
grid.arrange(myplot1, myplot2, myplot3, myplot4, ncol = 2)
你能澄清一下標籤應該是什麼樣子嗎?你只需要把小平面標籤全部推到左邊?或者您是否需要完全刪除facet標籤條? – joran
我只需要將標籤對齊到每個面板的左上角。我不清楚你的意思是通過刪除方面的標籤帶。 – Thraupidae
好的,然後看'?theme'並設置'strip.text'的hjust。 – joran