R corrplot produces empty plot

1.4k views Asked by At

I have a matrix with ~750k elements that I would like to plot with corrplot. It plots it alright without errors but the plot it produces is empty and only has the color scale. When using commnad-line R, it shows the plot in the "Quartz 2" window but then disappears after a few seconds. What gives?

library("corrplot")
mat <- matrix(data = rexp(200, rate = 10), nrow = 800, ncol = 800)
col1 <- colorRampPalette(c("#00007f", "#00007f", "#00007f", "#00007f", "blue", "cyan", "#00cc00", "yellow", "#FF7F00", "red"), interpolate = "linear", alpha = TRUE) 
corrplot(splotMat, is.corr = FALSE, method = "color", tl.pos = "n", col = col1(100), cl.lim = c(-0.14, 1))
1

There are 1 answers

6
r2evans On

I think the problem is not with the code as much as the resolution of your plotting window (i.e., sub-pixel plotting). I played with matrices of sizes below 500x500 and it showed just fine on my laptop screen. At around 550, I lost it (blank, as you saw). When I moved the window to my larger monitor, I was able to plot up to 800 (though it admittedly took a while).

To see if it was providing rendering at finer resolutions, I dumped it into a PDF and zoomed in:

## your data
library("corrplot")
mat <- matrix(data = rexp(200, rate = 10), nrow = 800, ncol = 800)
col1 <- colorRampPalette(c("#00007f", "#00007f", "#00007f", "#00007f", "blue",
                           "cyan", "#00cc00", "yellow", "#FF7F00", "red"),
                         interpolate = "linear", alpha = TRUE) 
## demonstration
pdf("foo.pdf", width = 20, height = 20)
corrplot(mat, is.corr = FALSE, method = "color",
         tl.pos = "n", col = col1(100), cl.lim = c(-0.14, 1))
dev.off()

The file will be fairly large (~8MB) but you can zoom in and see individual cell colors (faint as they may be).