R可视化:使用ggplot2的主成分双标图

2024-04-22  本文已影响0人  生信学习者2

介绍

使用ggplot2的主成分双标图

代码

library(ggbiplot)

data(iris)

iris.pca <- prcomp (~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width,
                    data=iris,
                    scale. = TRUE)
ggbiplot(iris.pca, obs.scale = 1, var.scale = 1,
         groups = iris$Species, point.size=2,
         varname.size = 5, 
         varname.color = "black",
         varname.adjust = 1.2,
         ellipse = TRUE, 
         circle = TRUE) +
  labs(fill = "Species", color = "Species") +
  theme_minimal(base_size = 14) +
  theme(legend.direction = 'horizontal', legend.position = 'top')
image.png
上一篇 下一篇

猜你喜欢

热点阅读