Reputation: 615
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)))
And this is the figure I get
As you can see, the numbers are overlapping in some, and invisible in others. How can I increase the width of the bars by a little bit so that the numbers are visible? Five digit is the largest number in my data.
Upvotes: 2
Views: 19599
Reputation: 1928
ggplot2 allows you to adjust the width like this:
+ geom_bar(stat = "identity", width = 1)
The width is, I think, from 0 to 1 where 1 means that the bars take up 100% of the available space and there's no space in between. If you like the amount of white space between them but want them wider, then just make your plot dimensions overall wider.
Upvotes: 7