Remove all x axis labels in ggplot

I need to delete everything on the x axis, including labels and elevations, so that only the y axis is marked. How should I do it?

In the image below, I would like clarity and all marks and marks to be removed so that there is only an axis.

Ggplot example

data(diamonds) ggplot(data = diamonds, mapping = aes(x = clarity)) + geom_bar(aes(fill = cut)) 

ggplot chart:

enter image description here

Desired chart:

enter image description here

+67
r ggplot2
Jan 29 '16 at 17:50
source share
1 answer

You need to set element_blank() to theme() elements you want to remove

 ggplot(data = diamonds, mapping = aes(x = clarity)) + geom_bar(aes(fill = cut))+ theme(axis.title.x=element_blank(), axis.text.x=element_blank(), axis.ticks.x=element_blank()) 
+167
Jan 29 '16 at 17:55
source share



All Articles