scaleZoom: Zoom in on a specified region of a data matrix

scaleZoomR Documentation

Zoom in on a specified region of a data matrix

Description

Returns the portion of a matrix based on the specified ranges of abscissa (x) and ordinate (y) values.

Usage

scaleZoom(x, y, z=NULL, zoom=NULL, logxy="y",
    xy.linked=FALSE, xlab="x", ylab="y", log.base=2)

Arguments

x

a numeric vector of abscissa values corresponding to the provided z matrix.

y

a numeric vector of ordinate values corresponding to the provided z matrix.

log.base

the base of the logarithm used to scale the output zoomed coordinates. See the help for the logxy input for more details. Default: 2.

logxy

a character string indicating containing either or both of the characters "x" and "y". If the character "x" is present in the string, the logarithm of the resulting zoomed x coordinate is returned use base log.base. A similar logic follows for the presence of character "y" in the string. For example, to take the log10 of both the zoomed x- and y-coordinates, one would set logxy="xy", log.base=10. If logarithms are used, the xlab and ylab strings are altered accordingly. Default: "y".

xlab

character string defining x-label. Default: "x".

xy.linked

a logical value. If TRUE, the algorithm used to define the output (zoomed) x- and y-coordinates as follows:

1

Let ix be the indices of x s.t. x[ix] is on the interval [zoom[1],zoom[2]].

2

Redefine x and y as x=x[ix] and y=y[ix].

3

Let iy be the indices of y s.t. y[iy] is on the interval [zoom[3],zoom[4]].

4

Redefine x and y as x=x[iy] and y=y[iy].

Thus, both x- and y-zoom conditions must be met for both coordinates. Default: FALSE.

ylab

character string defining x-label. Default: "y".

z

a matrix of numeric values whose x- and y-axis values are defined by the x and y vectors, respectively. This argument may be NULL signifying that no z matrix is present and (in this case) only the zoomed x and y coordinates will be returned in the output. Default: NULL.

zoom

a four-element numeric vector containing the ranges to zoom into the data in c(xmin, xmax, ymin, ymax) format. Default: NULL (no zoom).

Value

a named list containing the following components:

x

The zoomed portion of the input x vector.

y

The zoomed portion of the input y vector.

z

The zoomed portion of the input z matrix, if z is not NULL.

ix

The indices of the original x vector which span the range specified by zoom[1:2].

iy

The indices of the original y vector which span the range specified by zoom[3:4].

xlab

A character string defining an appropriate x-label for the zoomed x-coordinate output.

ylab

A character string defining an appropriate y-label for the zoomed y-coordinate output.

See Also

image, stackPlot.

Examples

## create an image 
x <- y <- seq(-4*pi, 4*pi, len=50)
r <- sqrt(outer(x^2, y^2, "+"))
z <- cos(r^2)*exp(-r/6)
image(x,y,z,col=gray((0:32)/32))

## zoom in on one portion of that image and 
## re-display 
zoom <- scaleZoom(x,y,z, zoom=c(-5,5,-1,10), logxy="")
image(zoom$x, zoom$y, zoom$z, col=gray((0:32)/32))

ifultools documentation built on July 14, 2022, 5:07 p.m.