2017-06-21 106 views
0

我有以下r中如何绘制方位饼图中ggplot

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

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

回答

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

enter image description here