Search code examples
rplotpie-chart

Error in pie3D (plotrix) in r


Lets make some data:

dat <- data.frame(art=c("Ål", "Gedde", "Brosme"), sum=c(708,3797,1385))

And when i plot this in a 3D plot, like this:

library(plotrix)
pie3D(dat$sum,labels=dat$art,explode=0.1, main="Arter")

This happens: pie3D plot

How can I avoid that red are below green?


Solution

  • Sometimes it helps to read the help:

    Due to the somewhat primitive method used to draw sectors, a sector that extends beyond both pi/2 and 3*pi/2 radians in either direction may not display properly. Setting start to pi/2 will often fix this, but the user may have to adjust start and the order of sectors in extreme cases

    pie3D(dat$sum,labels=dat$art,explode=0.03, start=pi/2, main="Arter")

    enter image description here

    (also, the explode=0.03 looks nicer imho)