boxed.labels {plotrix}R Documentation

Place labels in boxes

Description

Places labels in boxes on an existing plot

Usage

 boxed.labels(x,y=NA,labels,bg="white",border=TRUE,xpad=1.2,ypad=1.2,
  srt=0,cex=1,adj=0.5,...)

Arguments

x,y x and y position of the centers of the labels. x can be an xy.coords list.
bg The fill color of the rectangles on which the labels are displayed.
labels Text strings
border Whether to draw borders around the rectangles.
xpad,ypad The proportion of the rectangles to the extent of the text within.
srt Rotation of the labels. If 90 or 270 degrees, the box will be rotated 90 degrees.
cex Character expansion. See text.
adj left/right adjustment. If this is set outside the function, the box will not be aligned properly.
... additional arguments passed to text.

Details

The label(s) are displayed on a rectangular background. This may be useful for visibility. Only right angle rotations are allowed in boxed.labels. Important change: xpad and ypad are now the full proportion of the box to text, not half. The user can now call cylindrect or gradient.rect for the background rectangle.

Value

nil

Note

This function is best for regularly spaced labels where overlapping is not a problem. See thigmophobe.labels for placing labels where overlap is likely.

Author(s)

Jim Lemon

See Also

spread.labels, thigmophobe.labels

Examples

 x<-rnorm(10)
 y<-rnorm(10)
 plot(x,y,type="p")
 nums<-c("one","two","three","four","five","six","seven","eight","nine","ten")
 boxed.labels(x,y-0.1,nums)
 # now label a barplot
 xpos<-barplot(c(1,3,2,4))
 boxed.labels(xpos,0.5,nums[1:4])
 # perform a PCA on the "swiss" dataset and plot the first two components
 data(swiss)
 swiss.pca<-prcomp(swiss)
 plot(swiss.pca$rotation[,1:2],xlim=c(-1,0.2),main="PCA of swiss dataset",
  type="n")
 boxed.labels(swiss.pca$rotation[1:6],swiss.pca$rotation[7:12],ypad=1.5,
  colnames(swiss),bg=c("red","purple","blue","blue","darkgreen","red"),
  col="white")

[Package plotrix version 2.5-5 Index]