繁体   English   中英

如何在ggplot中绘制多面饼图

[英]how to plot faceted pie chart in ggplot

我在R中有以下数据框

 Equipment       Area         Count
    RTG           1            12     
    RTG           2            13
    STS           1            34
    STS           2            33
    RTG           3            22
    STS           3            21

我想用设备绘制多面饼图,并在饼图中计数。

我在R中使用以下代码

ggplot(data = test) + 
geom_bar(aes(x = "", y = Count, fill = Area), 
stat = "identity") +
geom_text(aes(x = "", y = Count, label = count),position = 
position_fill(width=1))+
coord_polar(theta = "y") +
facet_grid(Equipment ~ ., scales = "free") 

但是,它不产生任何图形。

ggplot(data = test, aes(x = "", y = Count, fill = Area)) + 
  geom_bar(stat = "identity") +
  geom_text(aes(label = Count), position = position_stack(vjust = 0.5)) +
  coord_polar(theta = "y") +
  facet_grid(Equipment ~ ., scales = "free")

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM