10.9 Changing the Appearance of Legend Labels
10.9.2 Solution
Use theme(legend.text=element_text())
(Figure 10.16):
# Create the base plot
pg_plot <- ggplot(PlantGrowth, aes(x = group, y = weight, fill = group)) +
geom_boxplot()
# Change the legend label appearance
pg_plot +
theme(legend.text = element_text(
face = "italic",
family = "Times",
colour = "red",
size = 14)
)

Figure 10.16: Customized legend label appearance
10.9.3 Discussion
It’s also possible to specify the legend label appearance via guides()
, although this method is a bit unwieldy. This has the same effect as the previous code:
10.9.4 See Also
See Recipe 9.2 for more on controlling the appearance of text.