I make some plot with ggplot2 like this:
library(ggplot2)
ggplot(df, aes(x, y, col= col))
geom_point()
Everything is good but as soon I set another legend title as shown 
How can I change just the title not the eastethic in the legend?
Data used here:
df <- data.frame(x= 1:10, y= 1:10, col= rnorm(10))
CodePudding user response:
You need guide_colourbar instead of guide_legend
ggplot(df, aes(x, y, col = col))
geom_point()
guides(col = guide_colourbar(title = "Some title"))

Though personally, I would normally just change the label of the color aesthetic:
ggplot(df, aes(x, y, col = col))
geom_point()
labs(color = "Some title")
Which gives the same result with fewer keystrokes.

