[R] Pie Chart Labels

Jim Lemon jim at bitwrit.com.au
Wed Sep 5 11:07:54 CEST 2007


Adam Green wrote:
> I am having trouble finding out how to adjust the position of labels on 
> pie charts.  For the small wedges, many of the labels overlap making it 
> impossible to read.  Is there any way to offset the labels so that they 
> don't overlap?
> 
Hi Adam,
There are three ways to adjust the positions of labels on a 3D pie chart 
(I'm assuming it's 3D from the word "wedges". If not, the following 
should still be useful).

The first is to change the position of the sectors by the "start" 
argument. Apart from being useful when very large sectors cause 
problems, changing the sector positions can sometimes alleviate minor 
crowding of the labels.

The second is to catch the return value of the pie3D function. This is 
the radial positions at which the labels have been placed. You can then 
alter this vector and pass it as the argument "labelpos". In this way 
you can spread out the labels for small sectors.

Finally, you can leave out the labels when you call pie3D and manually 
place labels using the "text" function. The chart is drawn on a plot 
that spans -1 to 1 in both directions, so it is relatively easy to work 
out where the labels should be.

A word of warning - when I read, "For the small wedges, many of the 
labels...", I felt that I should say that pie charts in general, and 3D 
ones in particular, are rarely successful with more than 4 or 5 sectors. 
In the R-news article that included pie3D, I included a pie chart that 
was very difficult for the viewer to extract the information that the 
creator intended. Depending upon what is to be represented, you might 
consider whether another method might be more successful.

Jim



More information about the R-help mailing list