How can I remove the legend title in ggplot2?

Solution 1:

I found that the best option is to use + theme(legend.title = element_blank()) as user "gkcn" noted.

For me (on 03/26/15) using the previously suggested labs(fill="") and scale_fill_discrete("") remove one title, only to add in another legend, which is not useful.

Solution 2:

You can modify the legend title by passing it as the first parameter to a scale. For example:

ggplot(carrots, aes(y=MeanLength, x=Farm, fill=Type)) + 
  geom_bar(position="dodge") +
  theme(legend.position="top", legend.direction="horizontal") +
  scale_fill_discrete("")

There is also a shortcut for this, i.e. labs(fill="")

Since your legend is at the top of the chart, you may also wish to modify the legend orientation. You can do this using opts(legend.direction="horizontal").

enter image description here

Solution 3:

You can use labs:

p + labs(fill="")

plot example