[R] Spie charts

Jim Lemon drj|m|emon @end|ng |rom gm@||@com
Tue Mar 30 10:58:22 CEST 2021


Hi Ferri,
Just for fun, I plotted six countries with the current COVID deaths,
per million against both population and median income. Even I was
surprised.

library(plotrix)
country<-c("USA","Brazil","India","UK","Czechia","Mexico")
COVIDdeath<-c(1694,1471,117,1858,2445,1553)
Countrypop<-c(332,214,1390,68,11,130)
poprad<-rescale(cumsum(c(0,Countrypop)),c(0,2*pi))
median_income<-c(65850,9130,2120,42220,21940,9480)
png("COVID_death_by_pop.png")
radial.pie(radial.extents=COVIDdeath,
 sector.edges=poprad,
 sector.colors=color.scale(median_income,extremes=c("red","green")),
 labels=country,radial.lim=c(0,2500))
color.legend(xl=-2600,yb=-2600,xr=500,yt=-2500,
 legend=seq(2000,66000,length.out=5),
 rect.col=color.scale(seq(2000,66000,length.out=5),extremes=c("red","green")))
text(0,2850,"COVID deaths per million population",xpd=TRUE)
text(-1095,-2700,"Median income USD",xpd=TRUE)
text(2000,-2600,"Sector angle = population",xpd=TRUE)
dev.off()


Jim

On Mon, Mar 29, 2021 at 2: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.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: COVID_death_by_pop.png
Type: image/png
Size: 40304 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20210330/99e3e90a/attachment.png>


More information about the R-help mailing list