I am using the corrplot()
function in R to create a correlation heatmap. I want to display the p-values for the correlations.
corrplot(as.matrix(M2), method="color", p.mat = as.matrix(p_mat2), sig.level=0.05, tl.cex=font_size, insig="p-value")
I would like to display really small p-values in some cases, and show more than two digits. I saw that there is the number.digits parameter, however this seems to be only for the display of the correlation coefficient. Is there any setting to control the number of digits for the displayes p-values?
The below works for me:
library(corrplot)
M = cor(mtcars)
corrplot(M, method = 'number', number.digits = 3) # colorful number
For more details check: https://github.com/taiyun/corrplot/blob/master/R/corrplot.R
In corrplot
each row and column is positioned on a grid and the distance between the cells is equal to 1. This means that you can add any text you want with the call to text()
function. Here is an example:
# generate M2 and p_mat2 since they were not provided
M2 <- matrix(runif(10), nrow=2)
p_mat2 <- matrix(runif(10, min=0, max=0.1), nrow=2)
# call corrplot and add p-values using text()
corrplot(as.matrix(M2), method="color", sig.level=0.05, tl.cex=1)
text(col(M2), row(M2), round(p_mat2, 5), cex=0.5)
Result:
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