问题
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