I am plotting correlation plot with corrplot. I want to plot also the correlation coefficients:
require(corrplot) test <- matrix(data = rnorm(400), nrow=20, ncol=20) corrplot(cor(test), method = "color", addCoef.col="grey", order = "AOE")
But they are too big in the plot:
Is there any way to make the font of the coefficent smaller? I've been looking at ?corrplot
but there are only parameters to change the legend and axis font sizes (cl.cex
and tl.cex
). pch.cex
doesn't work either.
The correlation coefficient value size in correlation matrix plot created by using corrplot function ranges from 0 to 1, 0 referring to the smallest and 1 referring to the largest, by default it is 1. To change this size, we need to use number. cex argument.
Go to the menu in RStudio and click on Tools and then Global Options. Select the Appearance tab on the left. Again buried in the middle of things is the font size. Change this to 14 or 16 to start with and see what it looks like.
Then, you can further adjust the font of code window, console, terminal, environment, and history panels via Tools >> Global Options >> Appearance >> Editor font size.
R package corrplot provides a visual exploratory tool on correlation matrix that supports automatic variable reordering to help detect hidden patterns among variables. corrplot is very easy to use and provides a rich array of plotting options in visualization method, graphic layout, color, legend, text labels, etc.
The option to use is number.cex=
. As in the following:
corrplot(cor(test), method = "color", addCoef.col="grey", order = "AOE", number.cex=0.75)
To make it dynamic, try number.cex= 7/ncol(df)
where df
is dataframe for which the correlation was run.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With