How to display coloured group correlations with scale_colour_manual in ggpairs (R)?
I'm using ggpairs for data with 3 groups. The problem is that not all variables have all groups and therefore, some correlations only need to show 2 groups. Because of the automatic alphabetical ordering of the groups by ggpairs, the colouring is not consistent. The first colour is always assigned to the first factor level. (For example: group 1 = red, group 2 = blue, group 3 = green. But with variables having only the second and last group: group 2 = red and group 3 = blue.)
I tried to solve this problem myself by adding a scale_colour_manual in the following way:
This seems to work for the density plots on the diagonal (ggally_densityDiag) and for the scatter plots in the lower part (ggally_points), but for the correlations (ggally_cor) I only get the overal (black) correlations and none of the coloured group correlations anymore. While they were displayed before, but with wrong matching of colours and groups. Why are they not displayed anymore?