r-当您在轴标题中进行上刻时,如何调整绘图区域,使其与其他图形相等



我遇到了一个困扰我的问题!像这样,轴标题中的上划似乎改变了绘图区域。在此处输入图像描述

您可以增加轴和轴之间的空间。title…

d <- dplyr::tibble(X=1:10,
Y=10:1)
p1 <- ggplot2::ggplot(d,ggplot2::aes(x=X,y=Y)) + 
ggplot2::geom_point() + 
ggplot2::xlab("test") +
ggplot2::theme(axis.title.x=ggplot2::element_text(margin=ggplot2::margin(t=10)))
p2 <- ggplot2::ggplot(d,ggplot2::aes(x=X,y=Y)) + 
ggplot2::geom_point() + 
ggplot2::xlab("test²") +
ggplot2::theme(axis.title.x=ggplot2::element_text(margin=ggplot2::margin(t=10)))
gridExtra::grid.arrange(p1,p2,nrow=1)

最新更新