很抱歉,我无法为我的图表提供数据。我的根本问题是,如果您使用以下 ggarrange 语法来组合 2 个图,我无法弄清楚如何控制 y 轴上打印的值:
gg.combined <- ggarrange(plot1, plot2, ncol = 1, nrow = 2, align = "v", heights = c(3, 1))
Run Code Online (Sandbox Code Playgroud)
当plot2
被渲染它在y轴这对情节本身精细了很多刻度线。在上面的ggarrange
命令中,我缩小plot2
了 1/3,所以刻度线会聚集在一起。如何重新缩放 y 轴,plot2
以便刻度线不会聚集在一起gg.combined
?或者我可能需要重新调整gg.combined
?
您可以手动指定刻度并在需要时增加刻度之间的空间。
例如
data(iris)
g1 <- ggplot(iris, aes(x = Sepal.Length, y = Petal.Length, col = Species)) + geom_point()
g2 <- ggplot(iris, aes(x = Sepal.Width, y = Petal.Length, col = Species)) + geom_point()
btw_tick <- 1 # space between 2 ticks
ggarrange(g1 + scale_y_continuous(breaks = seq(1,8, btw_tick)),
g2 + scale_y_continuous(breaks = seq(1,8, btw_tick * 3)),
ncol = 1, nrow = 2, align = "v", heights = c(3, 1))
Run Code Online (Sandbox Code Playgroud)