I am using corrplot to visualise correlations, however the title is quite high above the plot, and I would like to bring it closer. How do I do this?
Sample dataframe:
"VADeaths" <-
structure(c(11.7, 18.1, 26.9, 41, 66, 8.7, 11.7, 20.3, 30.9, 54.3, 15.4,
24.3, 37, 54.6, 71.1, 8.4, 13.6, 19.3, 35.1, 50), .Dim = c(5, 4),
.Dimnames = list(c("50-54", "55-59", "60-64", "65-69", "70-74"),
c("Rural Male", "Rural Female", "Urban Male", "Urban Female")))
Calculate the correlation and visualise
library(corrplot)
cors = cor(VADeaths)
corrplot(cors,tl.col="black",title="Example Plot",mar=c(0,0,5,0),tl.offset = 1)
By extending the margin to 5 above the plot I can at least get the title to appear in the plot, but cannot figure out how to bring the title closer to the plot and centred over the plot rather than also the space taken up by the labels.
The above looks like this:
I am wanting something more like this (ignore the fonts)
My actual plots have much smaller labels, so there is a gap of around 3-4cm between the labels and the title. I did not find that increasing the value in mar solved the issue.
You could use mtext
to add the title instead
corrplot(cors,tl.col="black", mar=c(0,0,5,0), tl.offset = 1)
mtext("Example Plot", at=2.5, line=-0.5, cex=2)
at
controls the horizontal position. line
controls the height. cex
for the size. ?mtext
to see more options