Tawk_Tomahawk
Tawk_Tomahawk

Reputation: 139

R Graphs: Decreasing extra space between main title and graph

I am trying to remove space between the title of my histogram and where the y axis begins. I have edited top, bottom, and side margins, but the space between title and y axis has remained the same. Any suggestions? Here is my code...

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)

Thank you!

Upvotes: 4

Views: 3139

Answers (1)

drammock
drammock

Reputation: 2543

One might wish that line.main would work as an argument to hist (analogous to cex.main and similar), but unfortunately that does not appear to be implemented. You can pass line=0 to hist, but it will affect x- and y-axis titles (and the subtitle, if there is one), not just the main title. To adjust only the main title, plot it separately:

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

Upvotes: 3

Related Questions