Closed teindor closed 3 years ago
The names are too long. You can use short-length names and small parameter cex
I have used it before with even longer names with no problems
Set number.cex=0.5, tl.cex = 0.8
and zoom large the plot.
I can get a readable figure with the code below.
library(corrplot)
library(RColorBrewer)
x = mtcars[,1:9]
colnames(x) =
c("Exposure", "Fear", "Depression", "Anxiety",
"Perceived Parental Support", "Parental Supervision",
"Negative Life Events", "Parent's Anxiety", "Parent's Depression")
M = cor(x)
corrplot(M, method = "color", type = "lower")
corrplot(M, method = "color", type = "lower", p.mat = cor.mtest(x)$p,
sig.level = 0.05, tl.col="black", addCoef.col = "black",
number.cex=0.75, col = brewer.pal(n = 8, name = "PuOr"), insig = "blank")
Hi I love your package and used it quite a bit. Recently, the figure became unreadable such that it is aligned to the bottom right and one value obscure another. The code I used is the following: library(corrplot) library(RColorBrewer) M = cor(cor.p) M colnames(p.mat)= c("Exposure", "Fear", "Depression", "Anxiety", "Perceived Parental Support", "Parental Supervision", "Negative Life Events", "Parent's Anxiety", "Parent's Depression") rownames(p.mat)=c("Exposure", "Fear", "Depression", "Anxiety", "Perceived Parental Support", "Parental Supervision", "Negative Life Events", "Parent's Anxiety", "Parent's Depression")
cor.mtest <- function(cor.p, ...) { mat <- as.matrix(cor.p) n <- ncol(cor.p) p.mat<- matrix(NA, n, n) diag(p.mat) <- 0 for (i in 1:(n - 1)) { for (j in (i + 1):n) { tmp <- cor.test(cor.p[, i], cor.p[, j], ...) p.mat[i, j] <- p.mat[j, i] <- tmp$p.value } } colnames(p.mat) <- rownames(p.mat) <- colnames(cor.p) p.mat }
p.mat <- cor.mtest(cor.p) p.mat
cp = corrplot(M, method = "color", type = "lower", p.mat = p.mat, sig.level = 0.05, tl.col="black", addCoef.col = "black", number.cex=0.75, col = brewer.pal(n = 8, name = "PuOr"), insig = "blank")
The figure and data are enclosed
corrplot data.txt