如何增加ggplot2中的条形大小?

max*_*oda 2 r ggplot2

ggplot(scount_all, aes(x=classes, y=frequency, group=seasons,fill=seasons)) +
  scale_fill_manual(name = "Seasons",values=bwPalette(4))+
  geom_bar(colour="black",stat="identity", position="dodge")+
  geom_text(aes(ymax=frequency,label = paste(sprintf("%s", frequency)),
                hjust= 0.5,vjust=-2,group=seasons),
            size = 2, position = position_dodge(width=.9)) +
  theme_bw()+
  theme(legend.key = element_rect(colour = "black")) +
  guides(fill = guide_legend(override.aes = list(colour = NULL)))
Run Code Online (Sandbox Code Playgroud)

这是我得到的数字

在此输入图像描述

正如您所看到的,一些数字是重叠的,而另一些数字则不可见。如何稍微增加条形的宽度以使数字可见?五位数是我数据中最大的数字。

Lau*_*raS 7

ggplot2 允许您像这样调整宽度:

 + geom_bar(stat = "identity", width = 1)
Run Code Online (Sandbox Code Playgroud)

我认为宽度是从 0 到 1,其中 1 表示条形占据 100% 的可用空间,并且条形之间没有空间。如果您喜欢它们之间的空白量但希望它们更宽,那么只需使绘图尺寸整体更宽即可。