How to create a boxplot using ggplot2 for single variable without X-axis labels in R?

The important part of a boxplot is Y−axis because it helps to understand the variability in the data and hence, we can remove X−axis labels if we know the data description. To create a boxplot using ggplot2 for single variable without X−axis labels, we can use theme function and set the X−axis labels to blank as shown in the below example.

Example

ggplot(df,aes(x=factor(0),y))+geom_boxplot()+theme(axis.title.x=element_blank(),axis.text.x=element_blank(),axis.ticks.x=element_blank())

Output

Updated on: 2026-03-11T23:22:53+05:30

5K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements