17

GGally::ggpairs plots nice graphs like following one. Only thing I seek to refine it even more is to remove all gridlines in upper part of plot, where is correlation coefficient. An maybe also draw rectangle around each upper graph.

library("GGally")
data(iris)
ggpairs(iris[, 1:4], lower=list(continuous="smooth", params=c(colour="blue")),
  diag=list(continuous="bar", params=c(colour="blue")), 
  upper=list(params=list(corSize=6)), axisLabels='show')

enter image description here

tonytonov
  • 25,060
  • 16
  • 82
  • 98
gutompf
  • 1,305
  • 3
  • 11
  • 9
  • This is off-topic on SO because it is focused entirely on code for specific software. Please review advice on software-related questions in the help center. – Nick Cox Feb 16 '14 at 11:12
  • Take a look at a [similar question](http://stackoverflow.com/questions/21716567/use-ggpairs-to-create-this-plot), may help. – tonytonov Feb 19 '14 at 10:19

1 Answers1

11

Check out this related question and my forked repo. Use assignInNamespace to modify ggally_cor function as shown in the aforementioned question.

The only thing that needs to be done is modifying theme call:

  theme(legend.position = "none", 
        panel.grid.major = element_blank(), 
        axis.ticks = element_blank(), 
        panel.border = element_rect(linetype = "dashed", colour = "black", fill = NA))

enter image description here

Community
  • 1
  • 1
tonytonov
  • 25,060
  • 16
  • 82
  • 98
  • Do I understand correctly that this approach requires rebuilding `GGally` package from the source? Or it has been (or will be) pushed to the original codebase? Thanks! – Aleksandr Blekh Sep 01 '14 at 05:45
  • @AleksandrBlekh 1) Yes, either that or just replace the function as described in the linked question via `assignInNamespace`; 2) I haven't contacted the package author/maintainer about that, really, so I'd say no. More than that, I'm not sure if that fix of mine is compatible with the current release of the package, though it most likely is. – tonytonov Sep 01 '14 at 07:07
  • Thank you for fast reply! If you don't mind taking a quick look, I'd appreciate your feedback on my question here: http://stackoverflow.com/q/25598485/2872891. – Aleksandr Blekh Sep 01 '14 at 07:29
  • Hi, again! Recently I installed your version of `GGally` and during testing discovered that `"circle"` argument of `ggcorr()`'s `geom` parameter doesn't work as expected. Have you noticed such behavior? Based on your changes, it should work just fine. What do you think? – Aleksandr Blekh Sep 09 '14 at 12:41
  • @AleksandrBlekh Can you give a minimal code? It might be a new version of the package or something else. I'll take a closer look at it. – tonytonov Sep 09 '14 at 13:59
  • I've found what was the problem. In my example, I was using `"circle"` argument of `geom` parameter. It appears that at some point the name has been changed to `"point"`, making the original option deprecated. Either that, or example that I was adapting simply used the wrong name. Anyway, `"point"` works, but visually not very pleasing IMHO, as circles have rough edges. Not a big deal, though. – Aleksandr Blekh Sep 11 '14 at 04:11