【发布时间】:2012-12-03 15:44:41
【问题描述】:
这是一个扩展问题:How to put labels over geom_bar for each bar in R with ggplot2
我的数据有一些负面影响,因此标签侵入了条形图。我该如何调整这个?我需要动态读取标签位置。
谢谢!
growth<-data.frame(ElapsedTimeMonths=c(3,6,12,24),MedianGrowth=c(-0.011,-0.002,0.014,0.052))
g<-ggplot(growth, aes(x=factor(ElapsedTimeMonths),y=MedianGrowth))
g<-g+geom_bar(position="dodge", stat="identity")
g<-g+scale_y_continuous(labels = percent)
g<-g+geom_text(aes(label=as.character(100*MedianGrowth)), position=position_dodge(width=0.9), vjust=-0.25)
g
【问题讨论】: