Tutorial3 min read

How to Remove Legend Title in ggplot2 (The Easy Way)

By Francesco Villasmunta
How to Remove Legend Title in ggplot2 (The Easy Way)

It's one of the most googled questions in the R community: "How do I remove the legend title in ggplot2?"

The Solution

Add this to your plot:

+ theme(legend.title = element_blank())

Example

ggplot(df, aes(x=Group, y=Value, fill=Group)) +
  geom_boxplot() +
  theme(legend.title = element_blank())

Alternative: Renaming the Legend

If you want to change the title instead of removing it, use the labs() function:

+ labs(fill = "New Title")

Note: If you mapped to color instead of fill, use labs(color = "New Title").

Never Memorize Syntax Again

Forgetting ggplot2 syntax is a rite of passage for every data scientist. But you don't have to.

With Plotivy, you just say "Remove the legend title" or "Change legend title to Treatment Group", and the AI updates the plot instantly.

Try Natural Language Plotting

Stop googling syntax. Start plotting.

Try Plotivy Free →

Start Analyzing Today

You don't need to be a data scientist to analyze data like one. Try Plotivy and turn your data into insights in minutes.

Get Started for Free →
Tags:#ggplot2#R#legend#tutorial