In this article, we will discuss how to remove the labels from the facet plot in ggplot2 in the R Programming language.
Facet plots, where one subsets the data based on a categorical variable and makes a series of similar plots with the same scale. We can easily plot a facetted plot using the facet_wrap() function of the ggplot2 package. When we use facet_wrap() in ggplot2, by default it gives a title to each plot according to the group they are divided into.
Syntax:
plot + facet_wrap( ~facet-variable)
Parameter:
- facet-variable: Determines the variable around which plots have to be divided.
Here, is a basic facet plot made using the diamonds data frame which is provided by R Language natively. We have used the facet_wrap() function with ~clarity to divide the plot into facets according to their clarity.
Example: Basic plot
R
library(ggridges)
library(tidyverse)
ggplot(diamonds, aes(x=price, y=color, fill=color)) +
geom_density_ridges()+
facet_wrap(~cut)
|
Output:

Remove labels from Facet plot
We can customize various aspects of a ggplot2 using the theme() function. To remove the label from facet plot, we need to use âstrip.text.xâ argument inside the theme() layer with argument ‘element_blank()’.
Syntax:
plot + theme( strip.text.x = element_blank() )
Example: Removing the label from facet plot
R
library(ggridges)
library(tidyverse)
ggplot(diamonds, aes(x=price, y=color, fill=color)) +
geom_density_ridges()+
facet_wrap(~cut)+
theme(strip.text.x = element_blank())
|
Output:

Learn to code easily with our course
Coding for Everyone. This course is accessible and designed for everyone, even if you're new to coding. Start today and join millions on a journey to improve your skills!Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated :
24 Oct, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...