• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Data Viz with Python and R

Learn to Make Plots in Python and R

  • Home
  • Seaborn
  • Matplotlib
  • ggplot2
  • Altair
  • About
    • Privacy Policy
  • Visualizing Activation Functions in Neural Networks
  • Confusion Matrix Calculator
  • Visualizing Dropout Rate in Neural Network
  • Visualizing Loss Functions in Neural Networks
  • Show Search
Hide Search

Multiple ways to remove legend in ggplot2

datavizpyr · April 19, 2023 ·

Last updated on August 13, 2025

Removing legends in ggplot2 is a common requirement when creating clean, professional data visualizations. While legends help identify different groups or categories, there are situations where they become redundant, clutter the plot, or aren’t needed for your specific visualization goals.

In this comprehensive ggplot2 legend removal tutorial, you’ll discover 4 different methods to remove legends from your R plots. Whether you’re preparing publication-ready figures, creating dashboard visualizations, or simply cleaning up your plots, these techniques will give you complete control over legend display.

4 Methods to Remove ggplot2 Legends

Quick overview of techniques covered:

  • theme(legend.position="none") – Remove all legends at once
  • guides(color="none") – Remove specific legend types selectively
  • show.legend=FALSE – Disable legends within individual geom layers
  • easy_remove_legend() – Use the ggeasy package for simplified syntax

Adding legend to a plot is often helpful to easily understand a plot. However there are scenarios legends can be redundant or we don’t need them.

In ggplot2, we have multiple options to remove legend in a plot. In this tutorial we will see four ways to remove legend with examples.

Let us load the packages needed.

library(tidyverse)
theme_set(theme_bw(16))

How to remove legend in ggplot2

Let us make a plot with ggplot2 with legend added by color argument to aes() in the boxplot below. Note we can also add legend with fill argument to aes() function in the plot belpw.

mpg |>
  ggplot(aes(y = fct_reorder(manufacturer, cty), 
             x = cty,
             color=manufacturer))+
  geom_boxplot()+
  labs(y="manufacturer")
ggsave("how_to_remove_legend_in_ggplot.png")
Four ways to remove legend in ggplot
Four ways to remove legend in ggplot

1. Removing legend with theme()

One of the ways to remove legends in a ggplot is to use theme() layer with legend.position=”none’ argument. This will remove all the legends in the plot.

mpg |>
  ggplot(aes(y = fct_reorder(manufacturer, cty),  
             x=cty, 
             color=manufacturer))+
  geom_boxplot()+
  labs(y="manufacturer")+
  theme(legend.position="none")
ggsave("remove_legend_in_ggplot_with_theme.png")
How to remove legend in ggplot with theme()
How to remove legend in ggplot with theme()

2. Removing legend with guides()

mpg |>
  ggplot(aes(y = fct_reorder(manufacturer, cty), 
             x=cty, 
             color=manufacturer))+
  geom_boxplot()+
  labs(y="manufacturer")+
  guides(color="none")
ggsave("remove_legend_in_ggplot_with_guides.png")
Remove ggplot2 legend with guides()
Remove ggplot2 legend with guides()

Removing legend with show.legend=FALSE inside geom_*()

We can also remove legend using show.legend=FALSE within geom_*. In this example we use show.legend=FALSE argument inside geom_boxplot().

mpg |>
  ggplot(aes(y = fct_reorder(manufacturer, cty),
             x = cty, 
             color=manufacturer))+
  geom_boxplot(show.legend=FALSE)+
  labs(y="manufacturer")
ggsave("remove_legend_in_ggplot_with_show_legend.png")
remove legend in ggplot within geom_*. using show_legend()
remove legend in ggplot within geom_*. using show_legend()

Removing legend with ggeasy’s easy_remove_legend()

Fourth way to remove legend that may be easy to remember is to use ggeasy package and use the function easy_remove_legend().

library(ggeasy)
mpg |>
  ggplot(aes(y = fct_reorder(manufacturer, cty), 
             x=cty, 
             color=manufacturer))+
  geom_boxplot()+
  labs(y="manufacturer")+
  easy_remove_legend()
ggsave("remove_legend_in_ggplot_with_ggeasy.png")
remove legend in ggplot2 using. ggeasy
remove legend in ggplot2 using. ggeasy

Explore the Complete ggplot2 Guide

35+ tutorials with code: scatterplots, boxplots, themes, annotations, facets, and more—tested and beginner-friendly.

Visit the ggplot2 Hub → No fluff—just code and visuals.

Related posts:

Customizing Mean mark to boxplot with ggplot2How To Show Mean Value in Boxplots with ggplot2? Scatterplot with marginal multi-histogram with ggExtraHow To Make Scatterplot with Marginal Histograms in R? ggforce geom_circle(): Annotate with a circleHow To Annotate a Plot with Circle in R Default ThumbnailHow to Make Axis Text Bold in ggplot2

Filed Under: ggplot2, R Tagged With: remove ggplot2 legend

Primary Sidebar

Python & R Viz Hubs

  • Seaborn Guide & Cookbook
  • ggplot2 Guide & Cookbook
  • Matplotlib Guide & Cookbook
  • Confusion Matrix Calculator
  • Visualizing Activation Functions
  • Visualizing Dropout
  • Visualizing Loss Functions

Buy Me a Coffee

Copyright © 2026 · Daily Dish Pro on Genesis Framework · WordPress · Log in

Go to mobile version