我正在尝试制作一些“关闭堆叠”的产品。使用Cowplot的情节。我可以使用以下MWE获得我想要的效果:
library(ggplot2)
library(cowplot)
disp_plot <- ggplot(data=mtcars,aes(x= hp,y=disp)) + geom_point()+
theme(plot.margin = unit(c(0.3,0.3,0.0,0.15), "cm"),
axis.text.x =element_blank(),axis.title.x =element_blank())
mpg_plot <- ggplot(data=mtcars,aes(x= hp,y=mpg)) + geom_point()+
theme(plot.margin = unit(c(0.0,0.3,0.0,0.15), "cm"),
axis.text.x =element_blank(),axis.title.x =element_blank())
qsec_plot <- ggplot(data=mtcars,aes(x= hp,y=qsec)) + geom_point()+
theme(plot.margin = unit(c(0.0,0.3,0.3,0.15), "cm"))
mp <- plot_grid(disp_plot, mpg_plot, qsec_plot,ncol = 1,align='v', axis = 'l')
请注意,mpg与其他人的垂直比例不同。为了使绘图的垂直尺寸相同,我还想使用&#34; align =&#39; hv&#39;&#34;在plot_grid中。但是,这会导致边距设置的间距恢复,并且数字会再次分开。有没有办法保存我的间距?