当轴标题中有上划线时,如何调整绘图区域以使其与其他图形相等?

问题描述

我遇到一个困扰我很多的问题! 这样,轴标题中的上标似乎改变了绘图区域。 enter image description here

解决方法

您可以增加axis和axis之间的间距。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,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)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...