Multi-level Pie Chart in R

我的未来我决定 提交于 2019-12-24 01:16:17

问题


I'd like to make a very simple multi-level pie chart like the one you see below:

As you can see I already know about sunburstR but (since I am looking for a simpler solution) that's not exactly how it should be. Additionally I'd prefer if I could easily export it as vector graphics. The second solution, using ggplot2 to do a plot in polar coordinates also appears quite complicated for such a simple plot.

I'd be happy if you could help me! Thanks in advance! SP


回答1:


In ggplot2 this is should do the trick:

    library("ggplot2")
    df <- data.frame(a = c(4, 3, 3, 8, 1, 1, 10),
                     b = c("x", "x", "x", "y", "y", "y", "z"),
                     c = c("x1", "x2", "x3", "y1", "y2", "y3", "z1"))

    ggplot(df, aes(x = b, y = a, fill = c))+
      geom_bar(stat = "identity")+
      coord_polar(theta="y")

I hope this helps. Cheers



来源:https://stackoverflow.com/questions/40300767/multi-level-pie-chart-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!