0

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))
Karolis Koncevičius
  • 9,417
  • 9
  • 56
  • 89
Coder3110
  • 77
  • 8
  • 1
    Please give a minimal working example, such as described [here](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). As a start, providing a small portion of your matrix would be helpful, such as `dput(Mat[1:20,1:20])`. – r2evans Dec 04 '14 at 18:04

1 Answers1

1

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).

r2evans
  • 141,215
  • 6
  • 77
  • 149
  • Thanks for the response. I would like to have the image it initially spits out and erases. I could just take a screen shot. But I it seems I will have to draw the plot pixel by pixel. Great. Thanks anyway. – Coder3110 Dec 04 '14 at 19:53
  • You could always use `png(...)` instead of `pdf(...)`, though you'll need to set the resolution and size large enough to give you the pixels you need (e.g., `png("foo.png", res = 600, width = 6, height = 6, units = "in")`). – r2evans Dec 04 '14 at 19:55
  • Change that ... `png("foo.png", res = 600, width = 20, height = 20, units = "in")` worked, 6 inches did not. Up the res, the width/height, or both. – r2evans Dec 04 '14 at 20:02
  • Using png does not work as expected. Before the image goes away it looks like this [link](http://s4.postimg.org/c2ni5ws3h/temp.png) but using png device makes the image like this [link](http://s24.postimg.org/gq25saa3p/temp2.png). Any Ideas? Thank you. – Coder3110 Dec 05 '14 at 16:08
  • I'm not certain why, but the first phase of drawing the plot looks like colors without alpha applied, and that matches your first link. The second link looks like what I get. What were you expecting to see? – r2evans Dec 05 '14 at 16:51
  • Basically, I want to be able to save the plots in the way they appear in my first link (which was a screen shot). That is how I want them to look - more 'filled' in, if you will. That way it's easy to see which regions of the matrix are correlated (red lines) or not. – Coder3110 Dec 05 '14 at 17:46