Entering edit mode

7 weeks ago

Rob
▴
60

Hi friends

I used the following code to draw a correlation plot. (corrplot package)

- How can I show p-value as size of circle in the plot?
- How can I add a legend showing size of circles related to p-value (the larger the p-value the smaller the circle size)
- how can I clean the circles, as in the image edge of circles' color are not very clean and clear.

code :

```
mat <- read.csv("Correlation_plot.csv", header = T)
# mat : is a matrix of data
# ... : further arguments to pass to the native R cor.test function
cor.mtest <- function(mat, ...) {
mat <- as.matrix(mat)
n <- ncol(mat)
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(mat[, i], mat[, j], ...)
p.mat[i, j] <- p.mat[j, i] <- tmp$p.value
}
}
colnames(p.mat) <- rownames(p.mat) <- colnames(mat)
p.mat
}
# matrix of the p-value of the correlation
p.mat <- cor.mtest(mat)
write.csv(p.mat, "p_value_corr_plot.csv")
```

and plot:

```
M <-cor(mat)
corrplot(M, type="upper", order="hclust", col=col, cl.cex = 1, tl.cex = 1,
tl.col = "black", tl.srt = 45, mar = c(0, 0, 0, 0),
p.mat = p.mat)
```

First: The image link is broken.

Second:

Read. The. Manual. Please.Thanks Arsenal, I editted the plot link. Can you please take a look? I don't know why the circles are spotty in the edge.

That looks pretty simple. How are you rendering the plot?

I exported the plot as tiff /jpg/ copy & paste. All were the same

Show us the code you're using to export the plot as an image. TIFF should retain full resolution. Try saving it to a pdf/svg.

Agree. SVG is an awesome format too.

Actually, I do not use code for exporting the image. I just use export button in R, window in the right down. Even before exporting, the plot does not have resolution in the plot area of R studio.

It is expected that the within-window render resolution is lower. Use export functions.