Menu

Tutorial5 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)

The ggplot2 legend title is the most Googled thing to remove in R. Here is every method, plus the Python/Matplotlib equivalents so you can do it in either language.

Quick Reference

0.Live Code: Legend Customization

1.Remove Legend Title (theme())

2.Remove Entire Legend

3.Per-Scale Control (guides())

4.Rename Instead of Remove

0. Live Code: Legend Customization

Three legend styles side by side: with title, without title, and direct labels. The Python/Matplotlib equivalents of ggplot2 legend controls.

Live Code Editor
Code EditorPython
Loading editor...
Live Preview

Preparing preview

Running once automatically on first load

Learn by Experimenting

This is a safe playground for learning! Try changing:

  • Colors: Modify color values to see different palettes
  • Numbers: Adjust sizes, positions, or data ranges
  • Labels: Update titles, axis names, or legends

Edit the code, run it, then open the full data visualization tool to continue with your own dataset.

1. Remove Legend Title with theme()

R / ggplot2

ggplot(df, aes(x, y, color = group)) +
  geom_point() +
  theme(legend.title = element_blank())

element_blank() removes the title while keeping the legend entries. This is the most common approach.

Try it

Try it now: turn this method into your next figure

Apply the same approach to your own dataset and generate clean, publication-ready code and plots in minutes.

Open in Plotivy Analyze

Newsletter

Get a weekly Python plotting tip

One concise tip each week for cleaner, faster scientific figures. Built for researchers who publish.

No spam. Unsubscribe anytime.

2. Remove the Entire Legend

R / ggplot2

ggplot(df, aes(x, y, color = group)) +
  geom_point() +
  theme(legend.position = "none")

When to Remove

Remove legends when using direct labels on the data, in faceted plots where the title is self-explanatory, or when the groups are obvious from context.

3. Per-Scale Control with guides()

R / ggplot2

ggplot(df, aes(x, y, color = group, size = value)) +
  geom_point() +
  guides(color = guide_legend(title = NULL),   # remove color title
         size = guide_legend(title = "Value"))  # keep size title

Use guides() when you have multiple scales and want to remove only specific legend titles.

4. Rename Instead of Remove

R / ggplot2

ggplot(df, aes(x, y, color = group)) +
  geom_point() +
  labs(color = "Treatment Group")   # rename instead

Chart gallery

Related chart types

Explore chart types where legend management matters most.

Browse all chart types →
Scatter plot of height vs weight colored by gender with regression line
Statisticalmatplotlib, seaborn
From the chart galleryCorrelation analysis between metrics

Scatterplot

Displays values for two variables as points on a Cartesian coordinate system.

Sample code / prompt

import matplotlib.pyplot as plt
import numpy as np
from scipy import stats
import pandas as pd

# Generate sample data
np.random.seed(42)
n_samples = 200
height = np.random.normal(170, 8, n_samples)
weight = height * 0.6 + np.random.normal(0, 8, n_samples) - 50
Multi-line graph showing temperature trends for 3 cities over a year
Time Seriesmatplotlib, seaborn
From the chart galleryStock price tracking over time

Line Graph

Displays data points connected by straight line segments to show trends over time.

Sample code / prompt

import matplotlib.pyplot as plt
import numpy as np

# Generate temperature data for 3 major US cities over 12 months
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
nyc = [30, 32, 40, 52, 65, 75, 82, 81, 74, 63, 50, 38]
miami = [65, 66, 70, 76, 82, 87, 90, 90, 87, 80, 72, 66]
chicago = [25, 27, 35, 48, 62, 72, 80, 79, 71, 60, 45, 32]

# Create figure with enhanced styling
Bar chart comparing average scores across 5 groups with error bars
Comparisonmatplotlib, seaborn
From the chart galleryComparing performance across categories

Bar Chart

Compares categorical data using rectangular bars with heights proportional to values.

Sample code / prompt

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from scipy import stats

# Generate performance scores for 5 treatment groups
np.random.seed(42)
groups = ['Control', 'Treatment A', 'Treatment B', 'Treatment C', 'Treatment D']
n_samples = 30
Box and whisker plot comparing gene expression across 4 genotypes with significance brackets
Distributionseaborn, matplotlib
From the chart galleryComparing experimental groups in scientific research

Box and Whisker Plot

Displays data distribution using quartiles, median, and outliers in a standardized format.

Sample code / prompt

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from scipy import stats

# Generate gene expression data for 4 genotypes
np.random.seed(42)
genotypes = ['WT', 'KO1', 'KO2', 'Mutant']
n_per_group = 20
Violin plot comparing score distributions across 3 groups with inner box plots
Distributionseaborn, matplotlib
From the chart galleryComparing treatment effects across groups

Violin Plot

Combines box plots with kernel density to show distribution shape across groups.

Sample code / prompt

import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
from scipy.stats import f_oneway

# Generate exam score data for 3 groups
np.random.seed(42)
control = np.random.normal(72, 12, 50)
treatment_a = np.random.normal(78, 10, 50)

Skip the Legend Code Entirely

Upload your data and describe the plot. Plotivy handles legend formatting automatically.

Try Plotivy
Tags:#ggplot2#R#legend#tutorial#ggplot remove legend#ggplot remove legend title

Found this helpful? Share it with your network.

FV
Francesco Villasmunta

Experimental Physicist & Photonics Researcher

Hands-on experience in silicon photonics, semiconductor fabrication (DRIE/ICP-RIE), optical simulation, and data-driven analysis. Built Plotivy to help researchers focus on discoveries instead of data struggles.

More about the author

Visualize your own data

Apply the techniques from this article to your own datasets. Upload CSV, Excel, or paste data directly.

Start Analyzing - Free