My question is twofold;
I have a ggpairs plot with the default upper = list(continuous = cor)
and I would like to colour the tiles by correlation values (exactly like what ggcorr does).
I have this:
I would like the correlation values of the plot above to be coloured like this:
library(GGally)
sample_df <- data.frame(replicate(7,sample(0:5000,100)))
colnames(sample_df) <- c("KUM", "MHP", "WEB", "OSH", "JAC", "WSW", "gaugings")
ggpairs(sample_df, lower = list(continuous = "smooth"))
ggcorr(sample_df, label = TRUE, label_round = 2)
I had a brief go at trying to use upper = list(continuous = wrap(ggcorr)
but didn't have any luck and, given that both functions return plot calls, I don't think that's the right path?
I am aware that I could build this in ggplot (e.g. Sandy Muspratt's solution) but given that the GGally package already has the functionality I am looking for I thought I might be overlooking something.
More broadly, I would like to know how we, or if we can, call the correlation values? A simpler option may be to colour the labels rather than the tile (i.e. this question using colour rather than size) but I need a variable to assign to colour...
Being able to call the correlation values to use in other plots would be handy although I suppose I could just recalculate them myself.
Thank you!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…