2014-12-12 3 views
1

ggplot2에 대한 간단한 질문이 있습니다.ggplot2 - 특정 범례 변경 또는 삭제

전설에서 변수 중 하나를 삭제하고 싶습니다. 아래 예제에서 trt1을 말하면됩니다.

어떻게하면됩니까? 나는 변수가 전설에서 제거되어야한다는 것을 여전히 계획하고 싶다.

도움 주셔서 감사합니다.

library(ggplot2) 

bp <- ggplot(data=PlantGrowth, aes(x=group, y=weight, fill=group)) + geom_boxplot() 

bp 

enter image description here

답변

1

사용이 :

다음은 간단한 예입니다. scale_fill_discrete는 당신이 필요로하는 무엇을 :

library(ggplot2) 

bp <- ggplot(data=PlantGrowth, aes(x=group, y=weight, fill=group)) + geom_boxplot() + 
    scale_fill_discrete(breaks=c("ctrl","trt2")) 

bp 

enter image description here