Skip to main content
v2026.11,858 entries · CC-BY 4.0
LAC HealthMedical & Research SuppliesReagents, PPE & instruments — chain-of-custody documented.Fast, traceable sourcing built for regulated research environments, from bench consumables to instrumentation.Shop lac.us CodeCASRAIlac.us

ggplot Titles: Plot Title, Subtitle and Legend Title with labs()

Set a ggplot title, subtitle and legend title with labs() or ggtitle(), then style, move or remove them with theme() and guide_legend().

Written and maintained by CASRAI Editorial Board

Last updated

In ggplot2 the plot title and the legend title are set in different places, and that is why most “ggplot titles” questions come down to one choice: labs() for the text, theme() for how it looks. The plot title is labs(title = "...") (or ggtitle("...")); the legend title is labs() with the name of the aesthetic the legend belongs to, for example labs(colour = "Cylinders"). This guide covers both, plus subtitle, caption, styling, position and removal, using the current ggplot2 reference pages.

What titles are used for in research plots

A figure in a paper or report usually needs a title that says what is plotted, a legend title that names the grouping variable with its units or meaning (not the raw column name), and often a caption for the data source. ggplot2 gives each of these its own label slot, so they can be set together in one labs() call. For the matching axis labels see axis titles and labels in R.

Install or access (official source only)

ggplot2 is an R package distributed through CRAN and is free to use. Install it once and load it in each session:

install.packages("ggplot2")
library(ggplot2)

The official reference for every function used below is the ggplot2 reference site.

Step-by-step: set the plot title, subtitle and legend title

1. Set the plot title and subtitle

Add labs() to the plot. The reference page for labs() lists title, subtitle, caption and tag as arguments, and gives this form in its own examples:

p + labs(title = "New plot title", subtitle = "A subtitle")

The subtitle is displayed below the title. ggtitle(label, subtitle = waiver()) is documented on the same page as the shortcut for the same job, so p + ggtitle("New plot title") and p + labs(title = "New plot title") are both correct.

2. Add a caption or a tag

By default the caption is displayed in the bottom-right of the plot and the tag at the top-left. The reference examples are p + labs(caption = "(based on data from ...)") and p + labs(title = "title", tag = "A").

3. Change the legend title (ggplot legend title)

The legend title is attached to an aesthetic, not to the word “legend”. The labs() documentation says the name of each extra argument “should be an aesthetic”, and gives p + labs(colour = "Cylinders") as the example. Use the aesthetic that actually produces the legend: colour (or color), fill, shape, size and so on.

ggplot(mtcars, aes(wt, mpg, colour = factor(cyl))) +
  geom_point() +
  labs(title = "Fuel economy by weight", colour = "Cylinders")

When a plot has several legends, set one label per aesthetic in the same call, for example labs(colour = "Cylinders", shape = "Gear"). A fixed colour scale has its own naming rules, covered in ggplot colour scales.

4. Set the legend title from the scale or the guide

Axis and legend labels can also be set in the scale. The labs() page says setting them there is recommended when you are changing other scale options at the same time, for instance scale_colour_manual(name = "Cylinders", values = ...). The legend itself is also a guide: guide_legend() takes a title argument, “a character string or expression indicating a title of guide”, so guides(colour = guide_legend(title = "Cylinders")) sets the same text at the guide level.

5. Style and position the titles

Text and appearance are separate. labs() only changes the words; the look is controlled in theme() with element_text():

  • plot.title and plot.subtitle: appearance of the title and subtitle; the title is left-aligned by default.
  • legend.title: appearance of the legend title. It inherits from the general title element, so a change to title reaches the plot title, axis titles and legend titles together.
  • plot.title.position: "panel" (the default) aligns titles and caption to the plot panels; "plot" aligns them to the entire plot.
  • legend.title.position: where the legend title sits relative to the main legend: "top", "right", "bottom" or "left".
p + theme(
  plot.title = element_text(face = "bold"),
  plot.title.position = "plot",
  legend.title = element_text(face = "italic"),
  legend.title.position = "top"
)

The guide_legend() page adds that the guide’s own theme argument partially overrides, and is combined with, the plot’s theme, so a legend can be styled for one guide only. Wider theme controls are in ggplot2 themes.

6. Remove a title

To remove a label, set it to NULL, as in p + labs(subtitle = NULL). For the legend title on one guide, guide_legend(title = NULL) hides it: “If NULL, the title is not shown.”

Output and how to read it

The rendered plot shows the title at the top (left-aligned to the panel unless you move it), the subtitle beneath it, the caption bottom-right and the tag top-left. Each legend shows its title above its keys by default unless legend.title.position moves it. A label you never set falls back to the default derived from the mapping, so a legend titled factor(cyl) means no label was supplied for that aesthetic. Examples of full plots are in scatterplots in R and bar plots in R.

Troubleshooting

The legend title did not change

Check the aesthetic name. labs() matches labels by aesthetic, so labs(fill = "Group") has no effect on a legend that is built from colour. Match the argument to the aesthetic in your aes() call.

The title is not aligned with the left edge of the figure

By default titles align to the plot panel. Set theme(plot.title.position = "plot") to align them to the whole plot.

I want the legend title above, beside or below the keys

Use theme(legend.title.position = "top") (or "right", "bottom", "left"), or pass the theme inside guide_legend() to affect one legend.

A scale and labs() both name the same legend

Pick one place per aesthetic and keep it there. The documentation recommends the scale when you are already changing other scale options, which keeps the name next to the other settings.

Free alternatives: ways to set the same title

ggplot2 itself is free, and it offers several equivalent routes to the same titles. Which to use depends on what else you are changing.

What you want Call Note from the ggplot2 reference
Plot title labs(title = "...") or ggtitle("...") Both are documented; ggtitle() also takes a subtitle.
Legend title, quick labs(colour = "...") Argument name must be an aesthetic.
Legend title with other scale options scale_colour_manual(name = "...") Recommended when changing other scale options.
Legend title on one guide guides(colour = guide_legend(title = "...")) title = NULL hides it.
Title appearance theme(plot.title = element_text(...)), theme(legend.title = element_text(...)) Both inherit from title.

FAQ

How do I add a title to a ggplot?

Add labs(title = "Your title") or ggtitle("Your title") to the plot with +.

How do I change the legend title in ggplot2?

Use labs() with the aesthetic that creates the legend, for example labs(colour = "Cylinders") or labs(fill = "Group"). You can also set name in the scale or title in guide_legend().

What is the difference between ggtitle() and labs(title = )?

Both set the plot title. ggtitle(label, subtitle) is the shorter form for title and subtitle; labs() can also set the caption, tag and every aesthetic label in one call.

How do I remove the legend title?

Use guides(colour = guide_legend(title = NULL)) for the relevant aesthetic. Setting a label to NULL in labs() removes that label.

How do I move the legend title?

Set legend.title.position in theme() to "top", "right", "bottom" or "left".

Sources (official docs)

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about ggplot Titles: Plot Title, Subtitle and Legend Title with labs()

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →