2014-09-26 2 views
0

stat_sum으로 빌드 한 ggplot2 그래프의 제목 범례를 변경하고 싶습니다. 여기 stat_sum은 합계 대신 비율을 사용하지 않습니다.ggplot2 사용시 제목 범례 변경 stat_sum

데이터 : 나는 결과없이 제목의 전설을 변경하는 다른 기능을 시도

sp <- ggplot(data,aes(conc2, Nsurv)) + 
stat_sum(aes(size = factor(..n..))) + 
labs(x = "concentration", 
y = "response") 

:

data <- structure(list(replicate = structure(c(1L, 2L, 3L, 1L, 2L, 3L, 
1L, 2L, 3L, 1L, 2L, 3L), .Label = c("A", "B", "C"), class = "factor"), 
conc = c(0, 0, 0, 0.074, 0.074, 0.074, 0.22, 0.22, 0.22, 
0.66, 0.66, 0.66), time = c(21L, 21L, 21L, 21L, 21L, 21L, 
21L, 21L, 21L, 21L, 21L, 21L), Nsurv = c(18L, 19L, 19L, 19L, 
19L, 18L, 16L, 16L, 18L, 3L, 3L, 3L), Nrepro = c(161L, 102L, 
128L, 151L, 73L, 60L, 98L, 52L, 123L, 0L, 5L, 0L), conc2 = c(0, 
0, 0, 0.074, 0.074, 0.074, 0.22, 0.22, 0.22, 0.66, 0.66, 
0.66)), .Names = c("replicate", "conc", "time", "Nsurv", 
"Nrepro", "conc2"), row.names = c(43L, 44L, 45L, 88L, 89L, 90L, 
133L, 134L, 135L, 178L, 179L, 180L), class = "data.frame") 

내가 가진 ggplot 객체를 생성

sp + guides(fill=guide_legend(title = "points")) #no change 
#or 
sp + guides(color=guide_legend(title = "points")) #no change 
sp + scale_fill_discrete(name = "points") #no change 
#or 
sp + guide_legend(title="points") #don't work 
#or 
sp + scale_colour_brewer(name = "points") #no change 
#or 
sp + scale_colour_hue("points") #no change 

어떤 아이디어?

답변

3

요인에 대한 크기 척도의 이름을 변경하려고합니다. 따라서 매개 변수를 scale_size_discrete에 전달해야합니다.

sp <- ggplot(data,aes(conc2, Nsurv)) + 
    stat_sum(aes(size = factor(..n..))) + 
    labs(x = "concentration", 
     y = "response") + 
    scale_size_discrete(name = "points")