theme(legend.text=element_text()) (Figure 10.16):
# Create the base plot ggplot(PlantGrowth, aes(x = group, y = weight, fill = group)) + pg_plot <- geom_boxplot() # Change the legend label appearance + pg_plot theme(legend.text = element_text( face = "italic", family = "Times", colour = "red", size = 14) )
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:
# Changes the legend title text for the fill legend + pg_plot guides(fill = guide_legend(title.theme = element_text( face = "italic", family = "times", colour = "red", size = 14)) )
See Recipe 9.2 for more on controlling the appearance of text.