抱歉,我无法提供图表数据。我的根本问题是,如果您使用以下ggarrange语法来组合2个图,那么我将不知道如何控制y轴上打印的值:
gg.combined <- ggarrange(plot1, plot2, ncol = 1, nrow = 2, align = "v", heights = c(3, 1))
当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))
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句