Reputation: 11
Is there any way of specifying both a 1) shape for individual points by a grouping variable, and 2) color for individual points by a different grouping variable in fviz_mfa_ind() from R package FactoExtra?
Specificizing a group in "habillage" as in the code below colors individual points by the specified palette, but I've been unable to figure out how to overlay varying the point shape by a different grouping variable within the main chunk of code.
A savvy coworked figured out a workaround by overlaying geom_point to vary the point shape by a different grouping variable:
fviz_mfa_ind(res.famd,
habillage = "Label", # color by groups,
addEllipses = TRUE, ellipse.type = "confidence",
repel = TRUE) + # Avoid text overlapping
geom_point(aes(shape=res.famd$call$quali.sup$quali.sup$Soil,
color=res.famd$call$quali.sup$quali.sup$Label), size=3)+
scale_shape_manual(name="Soil", values = c(15,17,18,19))
Is there a cleaner way to do this? I imagine it involves setting habillage to "none" and using the more specific commands (maybe col.ind, shape.ind) described here (https://cran.r-project.org/web/packages/factoextra/factoextra.pdf), but I haven't been able to figure out the correct syntax to achieve this.
I have also tried the description for solving a somewhat similar issue with making a PCA biplot described here: ([https://stackoverflow.com/questions/64267037/specify-different-pointshapes-for-var-and-ind-in-fviz-pca-biplot?rq=1]), but couldn't quite adapt it myself to fviz_mfa_ind().
The goal would be a figure like this (although this is a different kind of ordination made with a different package), where you can visually express two different grouping variables simultaneously for each individual point:
Hopefully I have provided all the necessary details, I can edit if need be. Thanks for any input.
Upvotes: 1
Views: 788