2014-06-07 6 views
3

누군가 포인트 크기를 변경하고 아래 코드에서 그룹 색상을 유지하는 방법을 알고 있습니까?ggbiplot - 포인트 크기 변경

그냥 geom_point(size = 8)을 추가하면 모든 포인트의 색상이 검은 색으로 변경됩니다.

코드 :

library(ggbiplot) 
data(wine) 
wine.pca <- prcomp(wine, scale. = TRUE) 
g <- ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, 
       groups = wine.class, varname.size = 8, labels.size=10 , ellipse = TRUE, circle = TRUE) 
g <- g + scale_color_discrete(name = '') #+ geom_point(size = 8) 
g <- g + opts(legend.direction = 'horizontal', 
       legend.position = 'top') 
print(g) 

답변

6

geom_point 내부 컬러 미적 추가 그룹에 의해 색깔 포인트를 유지합니다. 또한 optstheme으로 변경했습니다. opts은 (는) 사용되지 않기 때문에 변경되었습니다.

ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, group=wine.class, 
       varname.size = 8, labels.size=10, 
       ellipse = TRUE, circle = TRUE) + 
    scale_color_discrete(name = '') + 
    geom_point(aes(colour=wine.class), size = 8) + 
    theme(legend.direction ='horizontal', 
     legend.position = 'top') 
+0

덕분에 많은 :이 작동하는 간단한 솔루션, 나는 alpha=0을 설정하고 상기 geom_point 라인에 포인트를 플롯하여 기본 포인트 보이지 않게 다음을 제안 할 수는 있지만 – lroca

0

내 포인트를 만들려고 노력하면서이 질문을 만났습니다. . eipi10의 답은 간단하게 기본 지점을 그려서 포인트 으로 만들 때이 문제를 해결합니다. 빠른 응답 및 도움을

ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, group=wine.class, 
    varname.size = 8, labels.size=10, 
    ellipse = TRUE, circle = TRUE, 
    alpha=0 #here's the change 
) + 
scale_color_discrete(name = '') + 
geom_point(aes(colour=wine.class), size = 0.5) + #set size of smaller points here 
theme(legend.direction ='horizontal', 
    legend.position = 'top')