问题描述
如何在两个条形图中不带小数点的情况下将标签放在图中?
这是我的代码:
dados_gráfico_cursoanteriorsatisfação_PA <- PA_dados_desde_2015 %>%
filter(!is.na(qsd_3PA_curso_anterior_satisfação_rec)) %>%
group_by(anoletivo_cat) %>%
count(anoletivo_cat,qsd_3PA_curso_anterior_satisfação_rec) %>%
mutate(pct = n / sum(n),pct_label = scales::percent(pct))
dados_gráfico_cursoanteriorsatisfação_PA$qsd_3PA_curso_anterior_satisfação_rec <- factor(dados_gráfico_cursoanteriorsatisfação_PA$qsd_3PA_curso_anterior_satisfação_rec,levels = c("Very satisfied","Satisfied","Insatisfied","Very insatified"))
ggplot(dados_gráfico_cursoanteriorsatisfação_PA,aes(x= anoletivo_cat,fill = qsd_3PA_curso_anterior_satisfação_rec,y = pct)) +
geom_bar(position = "fill",stat="identity",width = 0.5) +
geom_text(aes(label = paste(pct_label),y = pct),position = position_fill(vjust = 0.5),colour = "black",size = 3.2) +
scale_y_continuous(labels = scales::percent) +
labs(y = " ",x = " ",fill=" ") +
theme_void() + scale_fill_brewer(palette="Paired") +
theme(legend.text = element_text(size = 8,colour = "black")) +
theme(axis.text = element_text(size = 8,colour = "black")) +
theme(legend.position = "bottom",legend.direction = "horizontal") +
guides(fill = guide_legend(reverse=TRUE)) +
theme(plot.margin = unit(c(1,1,1),"cm")) +
theme(panel.grid = element_line(colour="grey90")) +
theme(panel.grid.minor.y = element_line(color = "white"),panel.grid.major.x = element_line(color = "white"))
这是我得到的情节:
先谢谢你! :)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)