美文网首页
R可视化:使用ggplot2的主成分双标图

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

作者: 生信学习者2 | 来源:发表于2024-04-22 09:50 被阅读0次

介绍

使用ggplot2的主成分双标图

代码

  • 加载R包和数据
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

相关文章

网友评论

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

      本文链接:https://www.haomeiwen.com/subject/slbbxjtx.html