I am using autoplot() in R to create a biplot for wine dataset. Currently I have the correct plot, purple is white wines and red is red wines but no matter what I try I cannot get a legend to appear. I need a legend to the right of the plot.
autoplot(wine.pca, colour = colvec1[as.factor(wine$Colour)], label.size = 3,
loadings=TRUE, loadings.label=TRUE, loadings.label.colour='black',
loadings.label.vjust = 0,loadings.label.hjust=0,
loadings.colour='black', scale=0, loadings.label.size=6, repel=TRUE)+
xlab("Prinicpal component 1 (25.4%)")+
ylab("Principal component 2 (22.1%)")+
ggtitle("PC1 vs PC2")+
theme(plot.title=element_text(hjust=0.5, size=25))+
guides(fill=TRUE)+
theme(axis.title = element_text(size=15))+
scale_colour_manual("Type", values= colvec1, labels=wine$Colour, drop=FALSE)+
theme(legend.position="right")
I have tried all sorts, scale_color_manual, scale_color_fill, element_text for lengend and all sorts however no matter what nothing ever appears