Lattice- xyplot Yufeng Lin Haipeng Yao How to use xyplot • Xyplot(formula, data = parent.frame(), panel = if (is.null(groups)) "panel.xyplot" else "panel.superpose", allow.multiple, outer, aspect = "fill", as.table = FALSE, between, groups, key, auto.key = FALSE, legend, layout, main, page, par.strip.text, prepanel, scales, skip, strip = "strip.default", sub, xlab, xlim, ylab, ylim, drop.unused.levels, par.settings, perm.cond, index.cond, ..., default.scales, panel.groups = "panel.xyplot", subscripts, subset) parameters in the xyplot function: 1. formula: • The formula is generally of the form y ~ x | g1 * g2 * ..., • The formula can also be supplied as y ~ x | g1 + g2 + .... • The formula of the form ~ x | g1 * g2 * ... is also allowed. • The conditioning variables g1, g2, ... must be either factors or shingles. • The formula can involve expressions, e.g. sqrt(), log(). • A special case is when the left and/or right sides of the formula (before the conditioning variables) contain a `+' sign, e.g., y1+y2 ~ x | a*b. This formula would be taken to mean that the user wants to plot both y1~x | a*b and y2~x | a*b, but with the y1~x and y2~x superposed in each panel. The two parts would be distinguished by different graphical parameters. • To interpret y1 + y2 as a sum, one can either set allow.multiple=FALSE or use I(y1+y2). • A variation on this feature is when the outer argument is set to TRUE as well as allow.multiple. In that case, the plots are not superposed in each panel, but instead separated into different panels. • The x and y variables should both be numeric in xyplot, and an attempt is made to coerce them if not. However, if either is a factor, the levels of that factor are used as axis labels parameters in the xyplot function (2) 2. data: • A data frame containing values for any variables in the formula, as well as groups and subset if applicable. By default the environment where the function was called from is used. 3. allow.multiple, outer: • logical flags to control what happens with formulas like y1 + y2 ~ x. allow.multiple defaults to TRUE whenever it makes sense, and outer defaults to FALSE except when groups is explicitly specified or grouping doesn't make sense for the default panel function parameters in the xyplot function (3) 4. panel: • Once the subset of rows defined by each unique combination of the levels of the grouping variables are obtained, the corresponding x and y variables (or other variables, as appropriate, in the case of other high level functions) are passed on to be plotted in each panel. • The actual plotting is done by the function specified by the panel argument. • The panel function can be a function object or a character string giving the name of a predefined function. • Note it is not guaranteed that panel functions will be supplied only numeric vectors for the x and y arguments; they can be factors as well (but not shingles). Panel functions need to handle this case, which in most cases can be done by simply coercing them to numeric. Technically speaking, panel functions must be written using Grid graphics functions. However, knowledge of Grid is usually not necessary to construct new custom panel functions, there are several predefined panel functions which can help; for example, panel.grid, panel.loess, etc. • One case where a bit more is required of the panel function is when the groups argument is not null. In that case, the panel function should also accept arguments named groups and subscripts An useful panel function predefined for use in such cases is panel.superpose, which can be combined with different panel.groups functions determining what is plotted for each group. • A panel function can have two other optional arguments for convenience, namely panel.number and panel.counter. parameters in the xyplot function (3) 5.panel.groups: • Applies when panel is panel.superpose (which happens by default in these cases if groups is non-null) 6.aspect: • controls physical aspect ratio of the panels. It can be specified as a ratio (vertical size/horizontal size) or as a character string. 7.as.table: • logical that controls the order in which panels should be plotted: if FALSE (the default), panels are drawn left to right, bottom to top (as in a graph); if TRUE, left to right, top to bottom. 8.between: • A list with components x 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 panels in a page and any extra components are ignored. The result is used for all pages in a multipage display. parameters in the xyplot function (4) 9.Sub • character string or expression (or a ``grob'') for a subtitle to be placed at the bottom of each page. 10.xlab /(ylab) • character string or expression giving label for the x-axis/y-axis. Defaults to the expression for x/y in formula. Can be specified as NULL to omit the label altogether. 11.xlim • Normally a numeric vector of length 2 (possibly a DateTime object) giving minimum and maximum for the x-axis/y-axis, or, a character vector, expected to denote the levels of x/y.

1/--страниц