10.7 Removing a Legend Title

10.7.1 Problem

You want to remove a legend title.

10.7.2 Solution

Add guides(fill = guide_legend(title = NULL)) to remove the title from a legend, as in Figure 10.12 (for other aesthetics, replace fill with the name of the aesthetic, such as colour or size):

ggplot(PlantGrowth, aes(x = group, y = weight, fill = group)) +
  geom_boxplot() +
  guides(fill = guide_legend(title = NULL))
Box plot with no legend title

Figure 10.12: Box plot with no legend title

10.7.3 Discussion

It is also possible to control the legend title when specifying the scale. This has the same effect as the preceding code:

scale_fill_hue(guide = guide_legend(title = NULL))