drawGrid: Draws an n-times-k grid

Description Usage Arguments Value Author(s) See Also Examples

Description

Draws an n-times-k grid in the current plot with grid points (corners and intersections) (x,y) as given by the x and y arguments.

Usage

1
2
## Default S3 method:
drawGrid(x, y=NULL, fcn=lines, ...)

Arguments

x

Either an n-times-k matrix of all x coordinates in the grid, or a vector of length k, which then corresponds to a n-times-k matrix with rows all equal to x. If NULL, argument x is assumed to be a list containing the two elements x and y.

y

Either an n-times-k matrix of all y coordinates in the grid, or a vector of length n, which then corresponds to a n-times-k matrix with columns all equal to y.

fcn

Draw function to be applied to each row and column of grid coordinates.

...

Arguments passed to fcn.

Value

Returns a list with elements x and y, which both are n-times-k matrices of the x and the y coordinates of the grid points.

Author(s)

Henrik Bengtsson

See Also

grid.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
plot(0:20,0:20)

# Simple grid
drawGrid(2:8,2:8)

# Advanced grid
x <- seq(1,19,by=1/2)
y <- matrix(10:15, nrow=6, ncol=length(x))
y <- t(t(y) + sin(0.3*(1:ncol(y))))
drawGrid(x,y, fcn=function(...) { points(...); lines(...); }, col="red")

HenrikBengtsson/R.basic documentation built on May 6, 2019, 11:51 p.m.