How to Change Legend Labels in ggplot2 (With Examples)
The scale_fill_discrete() function is used to change the legend labels for discrete fill aesthetics in ggplot2. You can use the labels argument to specify the new labels. Syntax p + scale_fill_discrete(labels=c(‘label1’, ‘label2’, ‘label3’, …)) Example 1: Using scale_fill_discrete() function # Load the ggplot2 library library(ggplot2) # Create a sample data frame df <- data.frame( category = … Read more