我的代码:
ggplot(data=data,aes(x=month,y=as.numeric(properties),fill=show)) +
theme_light() +
geom_col(alpha=.8) +
geom_text(aes(label=round(..y../1000,1),group = c(show)),position=position_stack(vjust=.5),vjust=-.2,size=2) +
theme(axis.text.x = element_text(angle = 45,hjust = 1,vjust = 1,size=6),legend.position = "bottom",axis.title = element_text(size = 8),axis.title.y.left = element_text(size = 10)) +
ylab("Properties") + xlab("Month") +
scale_fill_manual("Show",values = c("YES" = '#b3b3b3',"NO" = '#8080ff'))
示例数据:
month show properties
-------------------
2017-05 NO 2.1
2017-05 YES 4.1
2017-06 NO 2.1
2017-06 YES 4.2
...
如何将每个组的总和更改为百分比比例,如何同时在每个条形上添加总单位和?