0
我想更改使用stat_sum
构建的ggplot2
图的标题图例。 这里stat_sum
不使用比例而是总和。使用ggplot2时更改标题图例stat_sum
数据:
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 <- ggplot(data,aes(conc2, Nsurv)) +
stat_sum(aes(size = factor(..n..))) +
labs(x = "concentration",
y = "response")
我尝试了不同的功能更改标题传说无果:
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
任何想法?