Laura Jonutytė
Laura Jonutytė

Reputation: 59

How to change the legend name when using qplot in R?

When I use qplot for a graph and try to change the legend name from "Temp" to "Average Temperature" it.. doesnt change. Do you know what could be wrong with my code:

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"))

Upvotes: 1

Views: 3989

Answers (1)

alistaire
alistaire

Reputation: 43354

You can use labs to set the legend title of each variable, e.g.

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

plot with edited legend title

Upvotes: 5

Related Questions