Plot Columns of Matrices in Grid Viewport

Share:

Description

Similar to matplot function, but drawn in grid viewport: Plot the columns of one matrix against the columns of another.

Usage

1
2
gmatplot(x, y, type = "p", lty = 1:5, lwd = 1, pch = NULL, 
         col = 1, cex = NULL, xlim = NULL, ylim = NULL, ...)

Arguments

x,y

vectors or matrices of data for plotting. The number of rows should match. If one of them are missing, the other is taken as y and an x vector of 1:n is used. Missing values (NAs) are allowed.

type

type what type of plot should be drawn. Possible types are

* "p" for *p*oints,

* "l" for *l*ines,

* "o" for both *o*verplotted.

lty,lwd

vector of line types and widths. The first element is for the first column, the second element for the second column, etc., even if lines are not plotted for all columns. Line types will be used cyclically until all plots are drawn.

pch

character string or vector of 1-characters or integers for plotting characters, see points. The first character is the plotting-character for the first plot, the second for the second, etc. The default is digits (1 through 9, 0) then the lowercase and uppercase letters.

col

vector of colours. Colours are used cyclically.

cex

vector of character expansion sizes, used cyclically. This works as a multiple of gpar("cex"). NULL is equivalent to 1.0.

xlim,ylim

ranges of x and y axes, as in plot.

...

Graphical parameters (see gpar). Hence, the high-level graphics control arguments described under gpar.

Details

Points involving missing values are not plotted.

The first column of x is plotted against the first column of y, the second column of x against the second column of y, etc. If one matrix has fewer columns, plotting will cycle back through the columns again. (In particular, either x or y may be a vector, against which all columns of the other argument will be plotted.)

Because plotting symbols are drawn with lines and because these functions may be changing the line style, you should probably specify lty=1 when using plotting symbols.

Author(s)

Original code by the R Core development team. Modified by Ingo Voglhuber.

See Also

gbarplot, gpie, gstars, gsymbols, gbxp

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
require(grDevices)

grid.newpage()

grid.rect()
gmatplot((-4:5)^2)

grid.newpage()

sines <- outer(1:20, 1:4, function(x, y) sin(x / 20 * pi * y))
grid.rect()
gmatplot(sines, pch = 1:4, type = "o", 
             col = rainbow(ncol(sines)))

grid.newpage()

grid.rect()
gmatplot(sines, type = "l", pch = 21:23, col = 2:5)