删除ggplot中所有x轴标签

标签 r ggplot2

我需要删除 x 轴上的所有内容,包括标签和刻度线,以便仅标记 y 轴。我该怎么做?

在下图中,我希望“清晰度”,并删除所有刻度线和标签,以便只有轴线在那里。

ggplot 示例

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

ggplot 图表:

enter image description here

所需图表:

enter image description here

最佳答案

您必须在需要删除的 theme() 元素中设置为 element_blank()

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())

关于删除ggplot中所有x轴标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35090883/

相关文章:

删除小数点y轴ggplot2

r - Rstudio 更有意义的窗口标题

javascript - 我怎样才能制作这样的情节?

r - 在 ggplot 的图例中添加背景透明度和自定义排序

r - 在 R 中,如何创建频率堆积条形图,但条形上有百分比标签,y 轴上有频率?

r - 按大小写对一系列列进行排序并将该排序顺序应用于另一列范围

r - R 中的条件交叉表

r - 在 r 中的 data.table 中缩放

R:如何有条件地更改 ggplot 分面图中使用的 3 个变量中的 1 个变量的值

python 情节9: color brewer not enough