
xyplot
, designed mainly
for two continuous variates, which produces Conditional
Scatterplots. The others are useful when one of the variates is a
factor. See details below.Most of the arguments documented here are also applicable for many of the other Trellis functions. These are not described in any detail elsewhere, and this should be considered the canonical documentation for such arguments.
Note that any arguments passed to these functions and not recognized by them will be passed to the panel function. Most predefined panel functions have arguments that customize its output. These arguments are described only in the help pages for these panel functions, but can usually be supplied as arguments to the high level plot.
xyplot(formula,
data = parent.frame(),
panel = "panel.xyplot",
aspect = "fill",
as.table = FALSE,
between,
groups,
key,
layout,
main,
page,
par.strip.text,
prepanel,
scales,
skip,
strip = "strip.default",
sub,
xlab,
xlim,
ylab,
ylim,
...,
subscripts,
subset)
barchart(formula, data, panel = "panel.barchart", box.ratio = 2,
horizontal, ...)
bwplot(formula, data, panel = "panel.bwplot", box.ratio = 1,
horizontal, ...)
dotplot(formula, data, panel = "panel.dotplot", ...)
stripplot(formula, data, panel = "panel.stripplot",
jitter = FALSE, factor = .5, box.ratio, ...)
y ~ x | g1 * g2 * ...
,
indicating that plots of y
(on the y axis) versus x
(on the x axis) should be produced condigroups
and subset
if applicable.
By default the environment where the function was called from is
used.bwplot, dotplot,
barchart
and stripplot
. Determines which of x
and
y
is to be a factor or shingle (y
if TRUE, x
otherwise). Defaults to x
and y
variables (or
some other variables, as appropriate, in the case ofx
and y
(both
usually 0 by default), numeric vectors specifying the space between
the panels (units are character heights). x
and y
are
repeated to account for all panepanel=panel.superpose
to allow display controls (color, lty etc) to vary according
to a grouping variable. Formally, if groups is specified, then
groups
along with subscripts
is passed The position of the legend can be controlled in either of two
possible ways. If a component called space
is present, the
key is positioned outside the plot region
layout
determines this arrangement. layout
is a numeric vector giving the number o
NULL
. Can be a character string, or a
list with components label, cex, col, font
. The label
tag can be omitted if it is the ficol, cex, font, lines
.
The first three control graphical parameters while the last is a
means of altering the height of the strips. This can be usefulx,y
(usually)
and returns a list containing four components xlim, ylim, dx,
dy
. If xlim
and ylim
are not explicitly specified
(possibly as components in
x
and y
of
the same form (described below). ComponFALSE
), replicated to be as
long as the number of panels in each page. If TRUE
, nothing
is plotted in the corresponding panel. Useful for arranging plots in
an informative manner.FALSE
, strips are
not drawn. Otherwise, strips are drawn using the strip
function, which defaults to strip.default
. See documentation
of strip.default
to see the main
for finer control options.groups
is specified, or if the panel function
accepts an argument named subscripts
. (One shdata
). Everything will be done on the data points for
which subset=TRUE
. In case subscripts
is TRUE, the
subscripts will correspond to the originax
in formula
. Specify as
NULL
to omit the label altogether. Fine control is possible,
see entry for sub
.y
in formula
. Fine control
possible, see entry for xlab
.xyplot,
bwplot
etc. For other functions, their individual documentation
should be studied in addition to this.shingle
,
banking
,
panel.xyplot
,
panel.bwplot
,
panel.barchart
,
panel.dotplot
,
panel.stripplot
,
panel.superpose
,
panel.loess
,
panel.linejoin
,
strip.default
,
Lattice
## Tonga Trench Earthquakes
data(quakes)
Depth <- equal.count(quakes$depth, number=8, overlap=.1)
xyplot(lat ~ long | Depth, 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)
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= 2)
panel.xyplot(x, y)
panel.loess(x,y, span=1)
},
aspect = "xy")
## banking
data(sunspot)
xyplot(sunspot ~ 1:37 ,type = "l", aspect="xy",
scales = list(y = list(log = TRUE)),
sub = "log scales")
data(state)
## user defined panel functions
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)
ltext(x=x, y=y, label=groups[subscripts], cex=.7, font=3))
data(barley)
barchart(yield ~ variety | year * site, data = barley, #aspect = 2.5,
ylab = "Barley Yield (bushels/acre)",
scales = list(x = list(0, abbreviate = TRUE,
minlength = 5)))
data(singer)
bwplot(voice.part ~ height, data=singer, xlab="Height (inches)")
dotplot(variety ~ yield | year * site, data=barley)
dotplot(variety ~ yield | site, data = barley, groups = year,
panel = function(x, y, subscripts, ...) {
dot.line <- trellis.par.get("dot.line")
panel.abline(h = y, col = dot.line$col,
lty = dot.line$lty)
panel.superpose(x, y, subscripts, ...)
},
key = list(space="right", transparent = TRUE,
points=list(pch=trellis.par.get("superpose.symbol")$pch[1:2],
col=trellis.par.get("superpose.symbol")$col[1:2]),
text=list(c("1932", "1931"))),
xlab = "Barley Yield (bushels/acre) ",
aspect=0.5, layout = c(1,6), ylab=NULL)
stripplot(voice.part ~ jitter(height), data = singer, aspect = 1,
jitter = TRUE, xlab = "Height (inches)")
## Interaction Plot
data(OrchardSprays)
bwplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
panel = "panel.superpose",
panel.groups = "panel.linejoin",
xlab = "treatment",
key = list(lines = Rows(trellis.par.get("superpose.line"),
c(1:7, 1)),
text = list(lab = as.character(unique(OrchardSprays$rowpos))),
columns = 4, title = "Row position"))
Run the code above in your browser using DataLab