0

How to plot the Significance codes in a correlation matrix

Signif. codes: 0 ‘’ 0.001 ‘’ 0.01 ‘’ 0.05 ‘.’ 0.1 ‘ ’ 1 Like this:

I've tried the followed code:

library(corrplot)
p.matc <- ggcorrplot::cor_pmat(mtcars)
testResc = cor.mtest(mtcars, conf.level = 0.95)
ggcorrplot::ggcorrplot(r, hc.order = FALSE, type = "lower",
                       lab_size = 3,pch.cex =5,digits =1,
                       tl.cex = 12, lab = TRUE,p.mat=p.matc,
                       outline.col = "white",
                       legend.title = "corr",title = "",
                       ggtheme = ggplot2::theme_classic(),
                       colors = c("#E46726", "white", "#6D9EC1"))

But I want something like this:

enter image description here

Carl Witthoft
  • 20,573
  • 9
  • 43
  • 73
Marcel
  • 147
  • 4
  • What is `r` in your code? – Quinten Aug 07 '23 at 15:24
  • 1
    Where exactly do you want the significance codes placed on that chart? What does your `R` code provided plot that you don't like? – Carl Witthoft Aug 07 '23 at 15:36
  • I want the significance codes placed on the inside of the boxes with the correlations. I need to show if the significance is significant at different significance levels. example: 0, 0.001, 0.01, 0.05 and 0.1 – Marcel Aug 07 '23 at 17:43
  • We still need to know what the object `r` is in your code. I edited another line so that a nonloaded function will run. But I suspect you are putting the wrong args into the wrong places in your ggcorrplot call as well – Carl Witthoft Aug 07 '23 at 21:46
  • Maybe the [gcorrplot2 package](https://github.com/caijun/ggcorrplot2) might be helpful? – pookpash Aug 08 '23 at 11:59

0 Answers0