所以我有这样的数据:
tag team count pct
E A 12 1.00
E B 5 .50
E C 1 .20
I B 5 .50
I C 4 .80
我想用这些数据制作一个多面饼图,但我无法让文本标签出现在图上的适当位置......我在这里做错了什么......
ggplot(data, aes(x = factor(1), y = pct, fill = tag)) +
geom_bar(stat = "identity", width = 1) +
coord_polar("y", start=0) +
theme_void()+ # remove background, grid, numeric labels
facet_wrap(~team)+
geom_text(aes(label = sprintf("%1.2f%%", 100*pct)))
你在正确的轨道上!
小调整:
ggplot(df, aes(x = factor(1), y = pct, fill = tag)) +
geom_bar(stat = "identity", width = 1) +
coord_polar("y", start=0) +
theme_void()+ # remove background, grid, numeric labels
facet_wrap(~team)+
geom_text(aes(label = sprintf("%1.2f%%", 100*pct)),position = position_stack(vjust = 0.5)) +
coord_polar(theta = 'y')
需要包括position= position_stack(vjust = 0.5)
和coord_polar(theta = 'y')
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句