Remove Legend Titles in Two Distinct Ways in ggplot2

This tutorial explains how to remove legend titles in two distinct aspects:


Create a base plot

# Packages and global themelibrary(ggplot2)library(dplyr)
theme_set(theme_bw(base_size = 14) + theme( legend.title = element_text( face = "bold", size = 15, color = "turquoise3")))
p <- iris %>% ggplot(aes(x = Sepal.Length, y = Sepal.Width, color = Petal.Length, shape = Species)) + geom_point(size = 4, alpha = .7, position = position_jitter(.1, .1, 123)) + scale_color_viridis_c(option = "B")
p

Remove the title of selected legend

Remove the title of the legend associated with the shape aesthetic. labs() is a quick solution to rename or remove legend titles (and axis titles as well).

p + labs(shape = NULL)

Alternatively, use the scale_* function to rename or remove legend (and axis) titles.

p + scale_shape_discrete(name = NULL)

Another option is to use the guides() function to rename or remove legend title. The following two codes are equivalent.

p + scale_shape_discrete(guide = guide_legend(title = NULL))p + guides(shape = guide_legend(title = NULL))

Remove the titles of all legends.

p + theme(legend.title = element_blank())