Search code examples
rpie-chart

Plot concentric pie charts in r


I'm trying to do a concentric pie chart. The internal pie represent three classes of subjects and each class has to be splitted in 3 sub-classes (of course the slices for the sub-classes have to be in line with the corresponding internal slice). this is what I tried:

layout(matrix(c(1,1,1,1,2,1,1,1,1), nrow=3)); pie(x=c(14,22,15,3,15,33,0,6,45),labels="",col=c("#f21c39","#dba814","#7309de")); pie(x=c(51,51,51),labels=c("O","VG","V"),col=c("#c64719","#0600f5","#089c1f"))

This worked, but the internal pie is too small. I tried to play with the radius option, but then the external slices are not correspondent to the internal ones. how can I adjust them?


Solution

  • Use par(new=TRUE) to overplot the pies rather than layout() in this case

    pie(x=c(14,22,15,3,15,33,0,6,45),labels="",
        col=c("#f21c39","#dba814","#7309de"))
    par(new=TRUE)
    pie(x=c(51,51,51),labels=c("O","VG","V"),radius=.5,
        col=c("#c64719","#0600f5","#089c1f"))
    

    enter image description here