且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在ggplot2中显示频率和barplot

更新时间:2023-11-26 11:42:28

geom_text is tha analog of text from base graphics:

p + geom_bar() + stat_bin(aes(label=..count..), vjust=0, 
                          geom="text", position="identity")

If you want to adjust the y-position of the labels, you can use the y= aesthetic within stat_bin: for example, y=..count..+1 will put the label one unit above the bar.

The above also works if you use geom_text and stat="bin" inside.

相关阅读

推荐文章