【问题标题】:How to change symbols of points for PCA ggplot?如何更改 PCA ggplot 的点符号?
【发布时间】:2021-10-12 05:29:21
【问题描述】:
biplot<-ggbiplot(pcobj = PCA,choices= c(1,2),scale = 1,groups = Fdata$Tissue,ellipse = TRUE)+ 
geom_vline(xintercept = 0, linetype = 3)+geom_hline(yintercept = 0, linetype = 3)         

  

【问题讨论】:

标签: r ggplot2 pca


【解决方案1】:

尝试添加geom_point(aes(shape=factor(something)))。以iris 数据为例,

library(ggbiplot)

ir.pca <- prcomp(iris[,1:4], center = TRUE,scale. = TRUE) 

ggbiplot(ir.pca, obs.scale = 1, var.scale = 1,groups = iris$Species, ellipse = TRUE)+geom_point(aes(shape=factor(iris$Species)))

ggbiplot(ir.pca, obs.scale = 1, var.scale = 1,groups = iris$Species, ellipse = TRUE, labels = )+
  geom_point(aes(shape=factor(iris$Species))) +
  guides(color = "none", shape = guide_legend(title = "New"))  +
  scale_shape_discrete(labels = c("a", "b", "c"))

【讨论】:

  • 如何从图例中删除组并重命名因子?
  • @SonamTashi 您要删除哪个图例?例如在我的代码中,要删除颜色,使用guides(color = "none"),要删除形状图例,使用guides(shape = "none")。为了重命名标题和因子名称,我添加了上面的代码
  • 另外,如何更改 gg-plot for PCA 的标题位置和字体?
  • @SonamTashi theme(text = element_text(family = "mono")) 将更改字体,+ggtitle("aaa") 将添加标题。
  • 感谢您的代码
猜你喜欢
  • 1970-01-01
  • 2021-03-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-11-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多