add.pie: Add pie plot to existing plot

add.pieR Documentation

Add pie plot to existing plot


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, ...)



a vector of non-negative numerical quantities. The values in z are displayed as the areas of pie slices.

x, y

the location of the centre of the pie on the x and y-scale of the existing plot.


one or more expressions or character strings giving names for the slices. Other objects are coerced by as.graphicsAnnot. For empty or NA (after coercion to character) labels, no label nor pointing line is drawn.


the radius of the pie in units of the y-scale


the circular outline of the pie is approximated by a polygon with this many edges.


logical indicating if slices are drawn clockwise or counter clockwise (i.e., mathematically positive direction), the former is default.


number specifying the starting angle (in degrees) for the slices. see pie for details.


the density of shading lines, in lines per inch. The default value of NULL means that no shading lines are drawn. Non-positive values of density also inhibit the drawing of shading lines.


the slope of shading lines, given as an angle in degrees (counter-clockwise).


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.


(possibly vector) argument passed to polygon which draws each slice.


(possibly vector) argument passed to polygon which draws each slice.


distance that the label is placed away from the pie (relative to the radius)


graphical parameters can be given as arguments to pie. They will affect the main title and labels only.


Because this function is intended to add pie plots to a map, the radius is scaled to units on the y-scale. This is more convenient than using the x-scale as 1 degree latitude is exactly 60 nautical miles. (The conversion from degrees to distance on the x-scale 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 re-sized and asp is not defined in par then the pies will end up being oval.


Adapted from the function pie by Hans Gerritsen

See Also



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)

mapplots documentation built on Aug. 25, 2023, 5:15 p.m.