Learn R Programming

zetadiv (version 1.2.1)

pie.neg: Pie Chart, considering negative values as zeros

Description

Plots a pie chart, considering negative values as zeros, for the purpose of illustrating variation partitioning.

Usage

pie.neg(
  x,
  labels = names(x),
  edges = 200,
  radius = 0.8,
  clockwise = FALSE,
  init.angle = if (clockwise) 90 else 0,
  density = NULL,
  angle = 45,
  col = NULL,
  border = NULL,
  lty = NULL,
  main = NULL,
  warning = TRUE,
  ...
)

Arguments

x

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

labels

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.

edges

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

radius

The pie is drawn centered in a square box whose sides range from -1 to 1. If the character strings labeling the slices are long it may be necessary to use a smaller radius.

clockwise

Logical indicating if slices are drawn clockwise or counter clockwise (i.e., mathematically positive direction, used by default).

init.angle

number specifying the starting angle (in degrees) for the slices. Defaults to 0 (i.e., '3 o'clock') unless clockwise is true where init.angle defaults to 90 (degrees), (i.e., '12 o'clock').

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, lty

(possibly vectors) arguments passed to polygon which draws each slice.

main

An overall title for the plot.

warning

Boolean value. Set to FALSE to avoid displaying a warning if some values are negative and set to 0.

...

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

Details

This function is identical to the function pie in {graphics}, except that it considers all negative values as zeros, to allow for plotting variation partitioning outputs. The original pie function returns an error when negative values are present. However, variation partitioning can return negative values, which can then be treated as zeros (Legendre & Legendre, 2008). This function allows direct use of the results from Zeta.varpart without editing the data.

References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988). The new S language. Wadsworth & Brooks/Cole.

Cleveland, W. S. (1985). The elements of graphing data. Wadsworth: Monterey, CA, USA.

Legendre, P. & Legendre, L.F. (2012). Numerical ecology, 3rd English edition. Elsevier Science BV, Amsterdam.

See Also

pie, Zeta.varpart

Examples

Run this code
# NOT RUN {
pie.neg(rep(1, 24), col = rainbow(24), radius = 0.9)
# }

Run the code above in your browser using DataLab