数据来自我正在参加的类中的在线文件,因此,如果您安装了GGPLOT2和GGFORTIFY软件包,则可以复制此文件。 下面的图 我希望GGPLOT看起来像
ggplot实际上看起来像
Edit: 在下面添加可重复的代码。
iris.res <-
iris %>%
select(Sepal.Length:Petal.Width) %>%
as.matrix(.) %>%
prcomp(., scale = F)
autoplot(iris.res, data = iris, size = 4, col = "Species", shape = "Species",
x = 1, y = 2, #components 1 and 2
loadings = T, loadings.colour = "grey50", loadings.label = T,
loadings.label.colour = "grey50", loadings.label.repel = T) + #loadings are arrows
geom_vline(xintercept = 0, lty = 2) +
geom_hline(yintercept = 0, lty = 2) +
theme(aspect.ratio = 1) +
theme_bw()
为了增加箭头长度,将the the the the the the the and的加载倍增。有了一些试验和精力,可以弄清楚使用什么数字。
将标签放在正确的位置,将PC轴乘以xend
调用中的相同值。