而不是当前构成图例键的灰色背景上的彩色线条,我希望键标签旁边有颜色的正方形或圆形,以便颜色易于看到。我怎样才能做到这一点?以下是用作示例的代码片段:
mry <- do.call(rbind, by(movies, round(movies$rating), function(df) {
nums <- tapply(df$length, df$year, length)
data.frame(rating=round(df$rating[1]), year = as.numeric(names(nums)),
number=as.vector(nums))
}))
ggplot(mry, aes(x=year, y=number, colour=factor(rating))) + geom_line() +
scale_colour_brewer(palette="YlGnBu")