[R] Merging labels on Pie chart

Jim Lemon jim at bitwrit.com.au
Sun Feb 24 03:46:55 CET 2013


On 02/24/2013 03:06 AM, Melanie Zoelck wrote:
> Dear R Help Members,
>
> I need to draw a pie chart for someone and there are 3 small slices in it identifying different species, all 0.7%, who’s labels overlap so you cannot read them. Is there a way to have only 1 label the three slices, so as to merge the three labels into one without merging the 3 slices? Alternatively, is there a way to extend the pointing lines, so that they could be different heights so as to avoid the overlap.
>
Hi Melanie,
Depending upon how much overlap there is, you might be able to use the 
floating.pie (plotrix) function:

species.pct<-c(50,30,14,3,2,1)
species.names<-c("Homo sapiens","Pan troglodytes",
  "Gorilla gorilla","Yeti\nasiaticus","Megapodus\nsasquatch",
  "Gargantua\neuropaceae")
library(plotrix)
par(mar=c(5,2,4,3))
plot(0,xlim=c(-1,1),ylim=c(-1,1),axes=FALSE,type="n",xlab="",ylab="")
radpos<-floating.pie(0,0,species.pct,radius=0.8)
radpos[4:6]<-c(5.95,6.1,6.25)
pie.labels(0,0,radpos,species.names,radius=1)

If this is not enough, I think Uwe's suggestion would work.

Jim



More information about the R-help mailing list