2016-10-27 5 views
3

ggbiplotスクリプトプロットには3つのグループがありますが、どのようにマーカーの色や形を変更できますか?ggbiplot - グループの色とマーカーを変更します

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') 

答えて

4

次のように動作します。凡例の

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") 

enter image description here

、トリックはscale_color_manualscale_shape_manualに同じnameを使用するように思われます。

関連する問題