【问题标题】:ggbiplot - change the group color and markerggbiplot - 更改组颜色和标记
【发布时间】:2017-03-10 08:01:57
【问题描述】:

在示例 ggbiplot 脚本图中有 3 个组,如何更改标记颜色和形状?

library(ggbiplot)
data(wine)
wine.pca <- prcomp(wine, scale. = TRUE)
ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, group=wine.class,
         varname.size = 3, labels.size=3, 
         ellipse = TRUE, circle = TRUE) +
  scale_color_discrete(name = '') +  
  geom_point(aes(colour=wine.class), size = 3) +
  theme(legend.direction ='horizontal', 
        legend.position = 'top')

【问题讨论】:

    标签: r pca ggbiplot


    【解决方案1】:

    以下对我有用。

    ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, group=wine.class,
         varname.size = 3, labels.size=3, ellipse = TRUE, circle = TRUE) +
    scale_color_manual(name="Variety", values=c("orange", "purple", "green")) +  
    scale_shape_manual(name="Variety", values=c(17:19)) +
    geom_point(aes(colour=wine.class, shape=wine.class), size = 3) +
    theme(legend.direction ="horizontal", 
          legend.position = "top")
    

    对于传说,诀窍似乎是对scale_color_manualscale_shape_manual 使用相同的name

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-26
      • 2015-02-10
      • 1970-01-01
      • 2020-08-16
      相关资源
      最近更新 更多