在R中使用qplot时如何更改图例名称?

时间:2016-05-30 16:56:51

标签: r ggplot2

当我使用qplot作为图表并尝试从" Temp"更改图例名称时到"平均温度"它......没有改变。你知道我的代码有什么问题吗?

qplot(Year,
       Temp,
       data = LithuaniaTemp,
       main = "Lithuania Average Temperature 1900-2013",
       geom = c("point","smooth")) +
 aes(colour = Temp) +
 scale_color_gradient(low="blue", high="red") +
 theme_fivethirtyeight() +
 scale_fill_continuous(guide = guide_legend(title = "Average Temperature"))

1 个答案:

答案 0 :(得分:3)

您可以使用labs设置每个变量的图例标题,例如

qplot(hp, disp, colour = factor(cyl), data = mtcars, geom = 'point') + 
    labs(colour = 'cylinders')

plot with edited legend title