Learn R Programming

plotrix (version 2.2-7)

fan.plot: Display a fan plot.

Description

Displays numerical values as the arcs of overlapping sectors.

Usage

fan.plot(x,edges=200,radius=1,col=NULL,align.at=NULL,labels=NULL,
 labelpos=NULL,label.radius=1.1,align="left",shrink=0.02,main="",
 ticks=NULL,include.sumx=FALSE,...)

Arguments

x
Vector of numbers.
edges
The number of edges with which to draw a circle.
radius
The radius of the sectors.
col
The colors with which to fill the sectors.
align.at
Where to align the sectors (see Details).
labels
Labels placed around the sector arcs.
labelpos
Optional circumferential positions for the labels.
label.radius
How far away from the sectors the labels will be placed. May be a vector with a radius for each label.
align
Position of the alignment of sectors (see Details).
shrink
How much to shrink each successive sector in user units.
main
Optional title for the plot.
ticks
The number of ticks that would appear on the circumference of the complete circle. Default is no ticks, TRUE gives the number of ticks equal to the integer sum of x, which is fairly sensible if x is a vector of integers.
include.sumx
Whether to include the sum of all x values as the largest sector.
...
Additional arguments passed to polygon.

Value

  • The circumferential positions of the labels in radians. These are returned in order of decreasing size of the values plotted.

Details

The fan plot is a variant of the pie chart that places the sectors "on top" of each other from the largest to the smallest. By default, the largest sector is centered with its circumferential arc upwards, giving the plot the appearance of a folding fan. Passing a value for align.at will place the point of alignment at that angle in radians. The sectors may be aligned at either the left or right edges or in the center. Note that align must be one of left right or center. Each successive sector is radially "shrunk" by a constant amount so that two equal sectors will both be visible. In cases where there are several segments with very small differences, the labels may be crowded. There is a simple routine in the function to spread out crowded labels, but it may not be sufficient for severe crowding. By capturing the return value and manually altering the label positions, the crowded labels can be separated. This new vector of positions may then be passed as labelpos.

See Also

floating.pie

Examples

Run this code
# IUCN counts of threatened species by geographical area
 iucn.df<-data.frame(area=c("Africa","Asia","Europe","N&C America",
  "S America","Oceania"),threatened=c(5994,7737,1987,4716,5097,2093))
 labelpos<-fan.plot(iucn.df$threatened,
  labels=paste(iucn.df$area,iucn.df$threatened,sep="-"),
  main="Threatened species by geographical area",ticks=276)
 # give the "Africa" label a bit more space with labelpos
 labelpos[2]<-1.1
 fan.plot(iucn.df$threatened,
  labels=paste(iucn.df$area,iucn.df$threatened,sep="-"),
  labelpos=labelpos,
  main="Threatened species by geographical area",ticks=276)
 # now do it with label.radius
 fan.plot(iucn.df$threatened,
  labels=paste(iucn.df$area,iucn.df$threatened,sep="-"),
  label.radius=c(1.15,1.2,1.2,1.2,1.2,1.2),
  main="Threatened species by geographical area",ticks=276)

Run the code above in your browser using DataLab