我要坚持两个地块没有主题之间的任何空间(因此它们共享一个轴)。
鉴于:
p1 <- qplot(1,1,xlab="")
p1 <- p1 +
theme(legend.position="none",
axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
plot.margin=unit(c(1,1,0,1), "cm"),
panel.margin=unit(c(1,1,0,1), "cm"))
p2 <- qplot(1,2)
grid.arrange(p1,p2)
主要生产:
我想,以消除两个地块之间的空白。
在我的印象调整高度,因为一直在做的宽度: 左对齐两个图形边缘(ggplot)是解决方案,但不能弄明白。
您应该提供plot.margin
两个情节和对于P1和上缘为P2下边距设置负值。 这将确保这两个情节连接。
p1 <- qplot(1,1,xlab="")+
theme(legend.position="none",
axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
plot.margin=unit(c(1,1,-0.5,1), "cm"))
p2 <- qplot(1,2)+
theme(legend.position="none",
plot.margin=unit(c(-0.5,1,1,1), "cm"))
grid.arrange(p1,p2)
尝试
+ labs(x=NULL)
要么
+ labs(x=NULL, y=NULL)
使用grid.arrange之前除去周围的图(P1,P2)的左侧和底部边缘
p1 <- qplot(1,1)+
theme_bw() +
theme(axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
plot.margin = rep(unit(0,"null"),4),
panel.margin = unit(0,"null"),
axis.ticks.length = unit(0,"null"),
axis.ticks.margin = unit(0,"null")) +
labs(x=NULL)
p2 <- qplot(1,2)+
theme_bw() +
theme(
plot.margin = rep(unit(0,"null"),4),
panel.margin = unit(0,"null"),
axis.ticks.length = unit(0,"null"),
axis.ticks.margin = unit(0,"null"))
grid.arrange(p1,p2)