我正在使用该包垂直patchwork
组合多个ggplot2
图。无论比例名称的长度如何,我都希望每个地块的比例直接在另一个上方。目前,这些天平并没有相互对齐。
我愿意使用ggpubr
,或者facet_grid()
他们是否可以使用,但我已经看到 facets不允许多个 scales,我还没有找到任何使用的解决方案ggpubr
library(ggplot2)
library(patchwork)
set.seed(0)
testdata <- data.frame(x=1:10, y=1:10, col=runif(10))
g1 <- ggplot(testdata, aes(x=x,y=y,col=col)) + geom_point() +
scale_color_gradient(name="Short")
g2 <- ggplot(testdata, aes(x=x,y=y,col=col)) + geom_point() +
scale_color_gradient(name="A rather longer name")
g1/g2
ggsave("testfile.tiff", units = "mm", device="tiff",
width=100, height=100, dpi = 100)
理想输出: