使用 theme_void r 查看栏 / texte d'axe / étiquettes 标签

问题描述

我在 iris 数据库上制作了一个图表,如下所示:

enter image description here

这是让我得到这张图的代码

    library(tidyverse)
iris %>%
  gather("Type","Value",-Species) %>%
  ggplot(aes(Species,Value,fill = Type)) +
  geom_bar(position = "dodge",stat = "identity") +
  theme_bw()+
  scale_fill_brewer(palette="Paired")+
  theme_void()+
  theme(legend.position = "right",legend.title = element_blank(),legend.text = element_text(size = 13))

我使用 theme_void 得到一个白色背景且没有线轴的图形。但它删除了三个物种(Verginica、Setosa...)的标签

我如何在每组条形的底部显示标签

R 提出的其他主题不适合我。

提前致谢

解决方法

只需将此添加回主题即可!

library(tidyverse)
iris %>%
  gather("Type","Value",-Species) %>%
  ggplot(aes(Species,Value,fill = Type)) +
  geom_bar(position = "dodge",stat = "identity") +
  theme_bw()+
  scale_fill_brewer(palette="Paired")+
  theme_void()+
  theme(legend.position = "right",legend.title = element_blank(),legend.text = element_text(size = 13),axis.title.x = element_text(),axis.text.x = element_text())

reprex package (v1.0.0) 于 2021 年 3 月 18 日创建