2

I am trying to create a correlation matrix using GGpairs, the scatterplots are coloured by group (reg or irreg). The correlation values plotted on the upper corner are not aligned, as you see in the image here the Cor, reg and irreg values are not aligned.enter image description here

The code I use is this:

ggpairs(data=dat4,
   columns=1:5, 
   title="correlation matrix",               
   mapping= aes(colour = irregular), 
   lower = list(
   continuous = "smooth",
   combo = "facetdensity",
   mapping = aes(color = irregular)))

The data is here: replicatable data

Any suggestion? Thank you thank you!

Chuck

Chuck C
  • 153
  • 2
  • 12

1 Answers1

3

This seems to work:

ggpairs(data=dat4,
        columns=1:5, 
        title="correlation matrix",               
        mapping= aes(colour = irregular), 
        lower = list(
          continuous = "smooth",
          combo = "facetdensity",
          mapping = aes(color = irregular)),
        upper = list(continuous = wrap("cor", size = 3, hjust=0.8)))

enter image description here

Sandipan Dey
  • 21,482
  • 2
  • 51
  • 63