[R] Pie chart
Jim Lemon
jim at bitwrit.com.au
Fri May 20 11:17:46 CEST 2011
On 05/19/2011 10:07 PM, Silvano wrote:
> I made a pie chart and the names of the levels are outside the circle.
> How do I put the names of the levels within each sector?
>
> names(tab13) = paste(c('Regular', 'Bom', 'Excelente'),
> round(100*prop.table(tab13), dig=1), "%")
> pie(tab13, col=c("LightYellow", "lightgreen", 'lightblue', 'white'),
> clockwise=F, radius=.7)
>
Hi Silvano,
I couldn't do it with "pie" from the graphics package as it doesn't
return the positions for the labels, but...
library(plotrix)
plot(c(-1,1),c(-1,1),type="n",axes=FALSE,xlab="",ylab="")
sector_angles<-floating.pie(0,0,tab13,
col=c("LightYellow", "lightgreen", 'lightblue', 'white'),
radius=.7)
boxed.labels(cos(sector_angles)*0.5,sin(sector_angles)*0.5,
names(tab13))
I had to make up the data, so it may not look like yours.
Jim
More information about the R-help
mailing list