Remove Legend Title from ggplot2 Plot in R (Example)


In this R post you’ll learn how to delete a legend title in a ggplot2 plot.

The content looks as follows:

Let’s jump right to the examples.


Example Data

In the example of this tutorial, we’ll use the following data frame as basement:

set.seed(864)                                       # Create random data
data <- data.frame(x = rnorm(100),
                   y = rnorm(100),
                   group = c(rep("A", 50), rep("B", 50)))

Furthermore, we need to install and load the ggplot2 package to RStudio:

install.packages("ggplot2")                         # Install and load ggplot2

Now, we can draw a plot based on the functions of the ggplot2 package as shown below:

ggp <- ggplot(data, aes(x, y, col = group)) +       # Create default ggplot2
ggp                                                 # Print plot


ggplot2 Plot with Legend Title in R

Figure 1: ggplot2 Plot with Legend Title.


Figure 1 shows the graph that we have created with the previous R code. It’s a scatterplot representing two data groups. On the right side of the plot, you can see a legend and a legend title.


Example: Create ggplot2 Scatterplot without Legend Title

In case we want to remove a legend title from a ggplot2 graphic, we can use the theme function and the legend.title argument. Have a look at the following R syntax and the resulting image:

ggp +                                               # Remove legend title
  theme(legend.title = element_blank())


ggplot2 Plot without Legend Title in R

Figure 2: ggplot2 Plot without Legend Title.


As you can see in Figure 2, we deleted the legend title from our graph.


Video, Further Resources & Summary

Do you need more explanations on the R codes of this article? Then I can recommend to watch the following video of my YouTube channel. I’m illustrating the topics of this tutorial in the video:


Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.

YouTube Content Consent Button Thumbnail

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.


In addition, you might read some of the related articles of this website:


You learned in this tutorial how to delete the heading of a ggplot legend in the R programming language. If you have further questions, let me know in the comments.


Subscribe to the Statistics Globe Newsletter

Get regular updates on the latest tutorials, offers & news at Statistics Globe.
I hate spam & you may opt out anytime: Privacy Policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.