[R] display two pie-charts

Barry Rowlingson B.Rowlingson at lancaster.ac.uk
Wed May 11 15:59:31 CEST 2005


Lars wrote:

> i'd like to compose a clock-like looking plot composed out of two 
> circles, each showing the length of a period (to compare them). first, 
> to do so, it looked the easiest by using pie(), just puting multiple 
> pie-charts over each other. the problem is that once the second pie is 
> drawn, it replaces the first one. does anybody know how to add a second, 
> smaller pie over an existing one, like a layer?

  pie() calls plot.new(), thus creating a new plot. Comment out the 
plot.new call and you'll have a pie() function that splats over the 
current plot.

  Suggest you copy 'pie' to something of your own:

  > clock = pie

  Then edit the 'clock' function, removing the 'plot.new' call.

  All 'pie' does is call 'polygon' with some sine and cosine trickery - 
you may be better off writing your own graphics function to do what you 
want. Reading the 'pie' code may help!

Baz




More information about the R-help mailing list