问题描述
这是让我得到这张图的代码:
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 日创建