【问题标题】:how to plot faceted pie chart in ggplot如何在ggplot中绘制多面饼图
【发布时间】:2019-09-15 02:04:47
【问题描述】:

我在 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") 

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

【问题讨论】:

    标签: r


    【解决方案1】:
    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")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-25
      • 1970-01-01
      相关资源
      最近更新 更多