corrplot fix title cut off type='upper'

2018-05-14

corrplot

When creating a correlation plot using type="upper", the default settings will cut off the title in the plot. Add an upper margin to fix mar=c(0,0,2,0).

library(datasets)
library(corrplot)
data(iris)

# Select the numeric columns
irisNumeric <- Filter(is.numeric, iris)
# Compute the correlation matrix
irisCor <- cor(irisNumeric)

corrplot(irisCor, method="color",
         type="upper",
         title="Correlation Plot: No Margin",
         tl.col="black", tl.srt=0,
         diag=FALSE)

corrplot upper no margin

corrplot(irisCor, method="color",
         type="upper",
         title="Correlation Plot: mar = c(0,0,2,0)",
         tl.col="black", tl.srt=0,
         # Margin added here
         mar=c(0,0,2,0),
         diag=FALSE)

corrplot with margin for title