autoKey: Automatic key placement

Description Usage Arguments Details Value Note See Also Examples

Description

Automatically places a key in the sparsest location of the space spanned by the the x and y input coordinates.

Usage

1
autoKey(x, y=NULL, args.=NULL, nquadrant=5)

Arguments

x

if y is not NULL, this argument is a numeric vector containing the abscissa (x-axis) values for the current plot. If y=NULL, this argument is taken as a numeric vector of ordinate (y-axis) values.

args.

a list of arguments that define the legend ala the key function. Default: NULL (no matpoints).

nquadrant

an integer denoting the number of quadrants to partition the space spanned by x and y. For example, if nquadrants=3, the x-y space is partitioned into a 3x3 grid of equisized blocks. Default: 5.

y

a numeric vector containing the ordinate (y-axis) values in the current plot. If NULL, the x input argument is taken as the y-axis values while the x-axis values are extracted from x via the positions function. If there are no positions available, then the sequence 1:length(x) is used as the x-axis positions. Default: NULL.

Details

The argument args. is a list of arguments that define the key and nquadrant is the number of equi-sized quadrants to use in dividing the space in both the x- and y-direction. e.g., if nquadrant=3, the x-y plane is partitioned into a 3x3 uniform grid and the position of the sparsest quadrant (as defined by sparsetQuadrant) is used to place the key. This function does not take into consideration lines connecting the data points and only considers the spatial distribution of the points in the x-y plane. Futhermore, this function assumes that par("usr") is approximately c(range(x),range(y)), i.e., that the user will not explicitly make space outside span of the data to place the key. In this case, the user should explicitly place the key as usual.

Value

no output is returned.

Note

The key as described by args. is positioned in estimated sparsest region of the specified data set.

See Also

autoText, sparsestQuadrant, mergeList.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
zkey <- list(x=-1,y=-1,
lines=list(type=c("o","l"), pch=c(18,0), lty=1, col=1:2),
border=1,
corner=c(1,1),
cex=1.5 )

old.mfrow <- par(mfrow=c(2,2))

## rectangular hole in cloud 
set.seed(100)
N <- 10024
y <- rnorm(N)
x <- seq(N)
xhole <- x > .4*N & x < .9*N
yhole <- y > -2 & y < 2
hole  <- xhole & yhole
y <- y[!hole]
x <- x[!hole]
plot(x, y, type="p")
autoKey(x, y, args=zkey)

## linear chirp (more room on left) 
y <- sin(.125*pi*100*((0:99)/100)^2)
plot(y, type="p")
autoKey(y, args=zkey)

## quadratic 
x <- seq(-5,5)
y <- x^2
plot(x,y,type="p")
autoKey(x, y, args=zkey)

## circle 
tt <- seq(0,2*pi,length=100)
x  <- sin(tt)
y  <- cos(tt)
plot(x, y, type="p")
autoKey(x, y, args=zkey)
par(old.mfrow)

ifultools documentation built on May 2, 2019, 4:48 p.m.

Related to autoKey in ifultools...