Remove all of x axis labels in ggplot

RGgplot2

R Problem Overview


I need to remove everything on the x-axis including the labels and tick marks so that only the y-axis is labeled. How would I do this?

In the image below I would like 'clarity' and all of the tick marks and labels removed so that just the axis line is there.

Sample ggplot

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

R Solutions


Solution 1 - R

You have to set to element_blank() in theme() elements you need 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())

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionVeddaView Question on Stackoverflow
Solution 1 - RDidzis ElfertsView Answer on Stackoverflow