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

Lau*_*ytė 1 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"))
Run Code Online (Sandbox Code Playgroud)

ali*_*ire 5

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

qplot(hp, disp, colour = factor(cyl), data = mtcars, geom = 'point') + 
    labs(colour = 'cylinders')
Run Code Online (Sandbox Code Playgroud)

具有已编辑图例标题的绘图