I am trying to manually change each Environment variable to a specific color but the code is not functioning.
Test1$Environment <- factor(Test1$Environment, levels = c(“HW2”, “HW1”, “C”, “LW1”, “LW2”))
fviz_pca_biplot(pca_res,geom = c(“point”),
label = “var”,
alpha.var = “contrib”, col.var = “contrib”,
fill.ind = Test1$Environment,
col.ind = “black”,
pointshape = 21, pointsize = 3,
repel=TRUE) +
labs(x = “PC1”, y = “PC2”,
title = “PCA of Saturation Treatment”)+
scale_color_manual(name = “Environment”,
labels = Test1$Environment,
values = c(rep(c(“red”,”orange”,”green”,”cyan”,”blue4″))))
The intial error: Error in scale_color_manual()
:
! Continuous values supplied to discrete scale.
ℹ Example values: 21.1541988025978, 20.902410547052, 21.2070579192902,
1.62597191194639, and 18.6731057903946
I tried making color a factor here:
fviz_pca_biplot(pca_res, aes(x,y,color=as.factor(Test1$Environment), geom = c(“point”))
Error with this attempt:
Error in max(axes) : invalid ‘type’ (list) of argument
Claire Henley is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.