I know how to use the PCA results to draw the circle, but failed to draw the x.lab
and the y.lab
based on the plotting results from s.class
.
How to make a plot as I posted here?
I would like to ask more about this.
How to make the points bigger or smaller according to another integer variable?
Can ggplot2
draw the same circle as s.class
? The previous answers do not show how to draw circles.
The size of the points cane adjusted using size. The ellipses can be added via stat_ellipsis
pca <- prcomp(iris[iris$Species %in% c("virginica","versicolor"),1:4], retx = TRUE, scale = TRUE,tol=0.4)
predicted <-predict(pca,iris[,1:4])
ggplot(data.frame(predicted))+aes(x=PC1,y=PC2,color=iris$Species)+geom_point(aes(size=iris$Sepal.Length))+stat_ellipse()+stat_ellipse(level=0.8)