Learn R Programming

lattice (version 0.2-3)

xyplot: Conditioning Plots

Description

Draw conditioning plots

Usage

xyplot(formula, ...)

Arguments

formula
a formula describing the form of conditioning plot. A formula of the form y ~ x | g1 * g2 * ... indicates that plots of y versus x should be produced conditional on the variable g1,g2,....
...
other arguments

synopsis

xyplot(formula, aspect = "fill", as.table = FALSE, between = list(x = 0, y = 0), data, groups = NULL, key = NULL, layout, main = NULL, page = NULL, panel = panel.xyplot, par.strip.text, prepanel, scales, skip = FALSE, strip = strip.default, sub = NULL, subscripts = !missing(groups), subset, xlab, xlim, ylab, ylim, ...)

Details

see the documentation for trellis.args

See Also

trellis.args, Lattice

Examples

Run this code
## Tonga Trench Earthquakes
data(quakes)
xyplot(long ~ lat , data = quakes)
Depth <- equal.count(quakes$depth, number=8, overlap=.1)
## panel.superpose. doesn't work very well as there are too many
## values of the grouping variable. See splom example.
xyplot(long ~ lat | Depth, groups = mag, panel = panel.superpose, data=quakes)
## Examples with data from `Visualizing Data' (Cleveland)
## (obtained from Bill Cleveland's Homepage :
## http://cm.bell-labs.com/cm/ms/departments/sia/wsc/, also
## available at statlib)
data(ethanol)
xyplot(NOx ~ E, data = ethanol)
xyplot(NOx ~ E | C, data = ethanol)
EE <- equal.count(ethanol$E, number=9, overlap=1/4)
## Constructing panel functions on the fly; prepanel
xyplot(NOx ~ C | EE, data = ethanol,
       prepanel = function(x, y) prepanel.loess(x, y, span = 1),
       xlab = "Compression Ratio", ylab = "NOx (micrograms/J)",
       panel = function(x, y) {
           panel.grid(h=-1, v= -1)
           panel.xyplot(x, y)
           panel.loess(x,y, span=1)
       },
       aspect = "xy")
xyplot(NOx ~ C | EE, data = ethanol, subset = C>8) # subset
data(melanoma)
## banking
xyplot(incidence ~ year, data = melanoma, aspect="xy",
       xlab = "Year", ylab = "Incidence", ylim = c(0,5))
data(sunspot)
xyplot(sunspot ~ 1:37 ,type = "l", aspect="xy")
data(state)
## user defined panel functions (needs knowledge of G2)
states <- data.frame(state.x77, 
                     state.name = dimnames(state.x77)[[1]], 
                     state.region = state.region) 
xyplot(Murder ~ Population | state.region, data = states, 
       groups = as.character(state.name), 
       panel = function(x, y, subscripts, groups)  
       grid.text(x=x, y=y, label=groups[subscripts],
                 gp = gpar(fontsize = 8),
                 default.units = "native"))

Run the code above in your browser using DataLab