add.pie  R Documentation 
This function is used by draw.pie
to add a pie plot at a specific location to an existing plot. It can be used directly but in general it is advisable to use draw.pie
instead.
add.pie(z, x = 0, y = 0, labels = names(z), radius = 1, edges = 200, clockwise =
TRUE, init.angle = 90, density = NULL, angle = 45, col = NULL, border = NULL,
lty = NULL, label.dist = 1.1, ...)
z 
a vector of nonnegative numerical quantities. The values in 
x, y 
the location of the centre of the pie on the x and yscale of the existing plot. 
labels 
one or more expressions or character strings giving names for the slices. Other objects are coerced by 
radius 
the radius of the pie in units of the yscale 
edges 
the circular outline of the pie is approximated by a polygon with this many edges. 
clockwise 
logical indicating if slices are drawn clockwise or counter clockwise (i.e., mathematically positive direction), the former is default. 
init.angle 
number specifying the starting angle (in degrees) for the slices. see 
density 
the density of shading lines, in lines per inch. The default value of NULL means that no shading lines are drawn. Nonpositive values of density also inhibit the drawing of shading lines. 
angle 
the slope of shading lines, given as an angle in degrees (counterclockwise). 
col 
a vector of colors to be used in filling or shading the slices. If missing a set of 6 pastel colours is used, unless density is specified when par("fg") is used. 
border 
(possibly vector) argument passed to polygon which draws each slice. 
lty 
(possibly vector) argument passed to polygon which draws each slice. 
label.dist 
distance that the label is placed away from the pie (relative to the radius) 
... 

Because this function is intended to add pie plots to a map, the radius is scaled to units on the yscale. This is more convenient than using the xscale as 1 degree latitude is exactly 60 nautical miles. (The conversion from degrees to distance on the xscale is less straightforward as it depends on the latitude).
The function obtaines the aspect ratio of the current plot from get.asp
in order to draw circular pies. If the plot window is resized and asp
is not defined in par
then the pies will end up being oval.
Adapted from the function pie
by Hans Gerritsen
draw.pie
plot(NA,NA, xlim=c(1,1), ylim=c(1,1) )
add.pie(z=rpois(6,10), x=0.5, y=0.5, radius=0.5)
add.pie(z=rpois(4,10), x=0.5, y=0.5, radius=0.3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.