2

I couldn't find any option to expand the margins for plot generated by corrplot.mixed in the corrplot package. Any suggestion would be appreciated!

library(corrplot) 
cor_matrix <- structure(c(1, 0.31596392056465, -0.120092224085334, -0.345097115278159, 
                          0.31596392056465, 1, 0.158912865564527, -0.606426850726639, -0.120092224085334, 
                          0.158912865564527, 1, -0.134795548155303, -0.345097115278159, 
                          -0.606426850726639, -0.134795548155303, 1), .Dim = c(4L, 4L), 
                        .Dimnames = list(NULL, c("var_1", "var_2", "var_3", "var_4")))

corrplot.mixed(cor_matrix, order = "AOE", upper = "ellipse", lower = "number", 
               tl.cex = 2, cl.cex = 2, number.cex = 2)
Tung
  • 26,371
  • 7
  • 91
  • 115
  • 1
    I suggest looking at the package function itself `fix(corrplot.mixed)` and editing the margins there. – CCurtis Aug 19 '16 at 00:52
  • 1
    What do you mean expand the margins? Do you mean just to alter is re `par(oma=rep(5,4))` or ..? – user20650 Aug 19 '16 at 00:54
  • @CCurtis: I modified their `mar = c(0, 0, 0, 0)` to `mar = c(5, 5, 5, 5)` in their [code](https://github.com/taiyun/corrplot/blob/master/R/corrplot.R) but nothing changed. I'll further into it – Tung Aug 19 '16 at 01:08
  • @user20650: I meant the bottom margin in the attached plot so that `-1` shows up in the legend. `par(oma=rep(5,4))` didn't help – Tung Aug 19 '16 at 01:11
  • 1
    increase the size of your graphics window / graphics output device: I see all the legend labels on my screen without adjustment. So try, for example, `pdf("test.pdf", height=10, width=10) ; corrplot(...) ; dev.pff()` – user20650 Aug 19 '16 at 01:25
  • @user20650: It works. Thanks for helping! – Tung Aug 19 '16 at 04:41
  • @user20650: If I save it to PNG or TIFF format, it doesn't work. Do you know why? Thanks! – Tung Aug 19 '16 at 06:18
  • 1
    have a look at `?png` and `?tiff`, they have different heoght / width units – user20650 Aug 19 '16 at 12:17
  • Thanks! I have to use `png(filetag, height = 800, width = 800)` instead of `dev.copy(png, filetag, width = 800, height = 800) – Tung Aug 21 '16 at 05:50
  • https://stackoverflow.com/questions/28847524/r-titles-cut-in-half-with-par – Hider1466 Apr 05 '17 at 01:46
  • 1
    I find it helps to change the *aspect ratio* of the graphics window/output device. When I'm displaying to the screen, a landscape sized window of 16:9 cuts off the top labels. But resizing the "zoom window" (R-Studio) to square, or even portrait-shaped, solves the problem. From the preceding comments the same workaround applies to PDF and PNG. – pbnelson Jun 01 '17 at 13:17

1 Answers1

1

Answer my own question for future readers

library(corrplot) 
library(scico)

col4 <- scico(100, palette = 'vik')
filetag <- "corrplot_result.png"

png(filetag, height = 800, width = 800)

  corrplot.mixed(cor_matrix, order = "AOE", upper = "ellipse", lower = "number", 
                 upper.col = col4, lower.col = col4,
                 tl.cex = 2, cl.cex = 2, number.cex = 2)
dev.off()

enter image description here

Tung
  • 26,371
  • 7
  • 91
  • 115