Reputation:
I would like the title to be centered above the two plots in my mfrow object. Indeed, I have just that working, but the title is too far above the plots, and is only half included because of this. Below is my code showing the issue. How can I move the title down to just above the plots in the center?
a=1
p = c(rnorm(1000,5,10))
l = c(rnorm(1000,10,5))
par(mfrow=c(1,2))
hist(p,main=NULL)
hist(l,main=NULL)
title(main=print(paste0("Histogram a=", a)),outer=T)
Upvotes: 1
Views: 1286
Reputation: 24074
If you set the line
parameter in the title
call to, for example, -2
, you can place the title closer to the histograms:
a=1
p = c(rnorm(1000,5,10))
l = c(rnorm(1000,10,5))
par(mfrow=c(1,2))
hist(p,main=NULL)
hist(l,main=NULL)
title(main=print(paste0("Histogram a=", a)),outer=T, line=-2)
Upvotes: 4