Chuck C
Chuck C

Reputation: 153

GGpairs, correlation values are not aligned

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

Upvotes: 2

Views: 2350

Answers (1)

Sandipan Dey
Sandipan Dey

Reputation: 23099

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

Upvotes: 3

Related Questions