R图:减少主标题和图

时间:2016-01-21 19:49:38

标签: r plot

我试图删除直方图标题和y轴开始位置之间的空格。我编辑了顶部,底部和侧边距,但标题和y轴之间的空间保持不变。有什么建议?这是我的代码......

par(mfrow=c(1,3), mar = c(4, 4, 4, 1) + 0.1, oma = c(1, 1, 3, 1))

hist(data$variable1, xlim = c(1,5), 
     main="Title here",  breaks=seq(1,5,1), 
     freq=TRUE, xlab=" ", ylim = c(0,18), 
     border="white", col="gray", cex.main = 2)

hist(data$variable2, xlim = c(1,5), 
     main="Title here", breaks=seq(1,5,1), 
     freq=TRUE, xlab=" ", ylim = c(0,18), 
     border="white", col="gray", cex.main = 2)

hist(data$variable3, xlim = c(1,5), 
     main="Title here", breaks=seq(1,5,1), 
     freq=TRUE, xlab=" ", ylim = c(0,18), 
     border="white", col="gray", cex.main = 2)

谢谢!

1 个答案:

答案 0 :(得分:3)

有人可能希望line.main可以作为hist的参数(类似于cex.main和类似的),但不幸的是,这似乎没有实现。您可以line=0传递给hist,但它会影响x轴和y轴标题(以及副标题,如果有的话),而不仅仅是主标题。要仅调整主标题,请单独绘制:

hist(rnorm(50), main=NA)
title("A close-set title", line=0)