【发布时间】:2020-08-11 19:23:41
【问题描述】:
我有兴趣直接从数据集中在 r 中绘制饼图,而不是使用 table 函数。
这是我目前所拥有的
ggplot(iris, aes(x= Species)) +
geom_bar(aes(y = (..count..)/sum(..count..), fill=factor(..x..)), stat= "count")+
geom_text(aes(label = scales::percent((..count..)/sum(..count..)),
y= ((..count..)/sum(..count..))), stat="count", vjust = -.25) +
coord_polar(theta = "y",start = pi / 3, clip = "off")
这是创建一个像下面这样的极坐标图
我期待的是这样的情节
非常感谢任何关于我哪里出错的建议。提前致谢。
【问题讨论】: