[R] Spie charts

Abby Spurdle @purd|e@@ @end|ng |rom gm@||@com
Mon Mar 29 22:57:54 CEST 2021


I couldn't find a predefined function for this purpose.
However, it wouldn't be too difficult to write a pair of functions.

The big question is how flexible does the rendering function need to be?

#plot from angles, distances, etc
#(angles on arbitrary scale)
spiechart.render <- function (
    angle=1, distance, ...,
    circd= stdd, labd = 1.25 * stdd,
    main="", labs="", line.col="black", area.col="white",
    stdd = mean (distance) )
{   n <- length (distance)
    angle <- rep_len (angle, n)
    angle <- 2 * pi * angle / sum (angle)
    <rest of code>
}

#compute angles and distances, from data
#(then call rendering function)
spiechart <- function (
    <rest of code>
    spiechart.render (angle, distance, ...)
}

Partially off-topic remarks:
I know there's some criticism of this approach.
However, the OP never stated the purpose.
And this approach could be useful in some cases.
Say for modelling certain ecological or weather events.
Where for each event, there's a categorical date (such as month) and a
magnitude/etc.
And then, in the top level function from above, the angles and
distances would be the result of aggregation functions.


On Mon, Mar 29, 2021 at 4:59 AM Ferri Leberl <ferri.leberl using gmx.at> wrote:
>
> Dear ∀,
> Ist there a function to plot "spie charts" in R?
> https://en.wikipedia.org/wiki/spie_chart
> (These are a combination of pie charts and radial pie charts, where the angle represents one dimension and the radius of the respective sector another dimension)
> Thank you in advance!
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list