add.pie {mapplots} | R Documentation |
Add pie plot to existing plot
Description
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.
Usage
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, ...)
Arguments
z |
a vector of non-negative numerical quantities. The values in |
x , y |
the location of the centre of the pie on the x and y-scale 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 y-scale |
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. Non-positive values of density also inhibit the drawing of shading lines. |
angle |
the slope of shading lines, given as an angle in degrees (counter-clockwise). |
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) |
... |
|
Details
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).
Note
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.
Author(s)
Adapted from the function pie
by Hans Gerritsen
See Also
Examples
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)