Learn R Programming

TeachingDemos (version 2.13)

pairs2: Create part of a scatterplot matrix

Description

This function is similar to the pairs function, but instead of doing all pairwise plots, it takes 2 matricies or data frames and does all combinations of the first on the x-axis with the 2nd on the y-axis. Used with pairs and subsets can spread a scatterplot matrix accross several pages.

Usage

pairs2(x, y, xlabels, ylabels, panel = points, ..., row1attop = TRUE, gap = 1)

Value

This function is run for the side effect of the plot. It does not return anything useful.

Arguments

x

Matrix or data frame of variables to be used as the x-axes.

y

Matrix or data frame of variables to be used as the y-axes.

xlabels

Labels for x variables (defaults to colnames of x).

ylabels

Labels for y variables (defaults to colnames of y).

panel

Function to do the plotting (see pairs).

...

additional arguments passed to graphics functions

row1attop

Logical, should the 1st row be the top.

gap

Distance between plots.

Author

Greg Snow, 538280@gmail.com

Details

This functios is similar to the pairs function, but by giving it 2 sets of data it only does the combinations between them. Think of it as giving the upper right or lower left set of plots from pairs. If a regular scatterplot matrix is too small on the page/device then use pairs on subsets of the data to get the diagonal blocks of a scatterplot matrix and this function to get the off diagonal blocks.

See Also

pairs, splom in the lattice package

Examples

Run this code
pairs2(iris[,1:2], iris[,3:4], col=c('red','green','blue')[iris$Species])

# compare the following plot:
pairs(state.x77, panel=panel.smooth)

# to the following 4 plots

pairs(state.x77[,1:4], panel=panel.smooth)
pairs(state.x77[,5:8], panel=panel.smooth)
pairs2( state.x77[,1:4], state.x77[,5:8], panel=panel.smooth)
pairs2( state.x77[,5:8], state.x77[,1:4], panel=panel.smooth)

Run the code above in your browser using DataLab