本文介绍了R中的多级饼图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个非常简单的多级饼图,如下图所示:

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

如您所见,我已经对sunburstR有所了解,但是(因为我正在寻找一个更简单的解决方案)这并不是应该的。另外,我希望可以轻松将其导出为矢量图形。
第二种解决方案,使用ggplot2在极坐标中进行绘图,对于这样一个简单的绘图也显得相当复杂。

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.

如果您愿意,我会很高兴帮我!提前致谢!
SP

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

推荐答案

在ggplot2中,这应该可以解决问题:

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

这篇关于R中的多级饼图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 11:06