panel.xy: Flexible panel.xyplot replacement

Description Usage Arguments Details Author(s) See Also Examples

Description

panel.xy is used like panel.xyplot but offers more features. In particular, it can add an lqs resistant regression line besides a normal one, can plot a prediction interval around the standard regression line, can add text indicating correlation and number of data points, and automatically uses different colors and line styles.

Usage

1
2
panel.xy(x, y, type = "p,r,r.pred,r=,N=,grid",
         r.min = 0.5, level = 0.8, unicolor = FALSE, ...)

Arguments

x

Vector of x coordindates for the plot.

y

Vector of x coordindates for the plot. Pairs (x,y) containing NAs will be filtered out.

type

A character vector (or single comma-separated string) of options to use for plotting. Entries "p", "l", "b", "o", "h", "s", "S" are handled just as plot or panel.xyplot would (namely as points, lines, both, both overplotted, histogram lines, stair steps, stair steps with vertical preference). "g" adds a coordinate grid via panel.grid. "r" adds an lm regression line. See r.min and unicolor for details. The line is suppressed if there are less than 8 points. "r.pred" adds a prediction interval around the "r" line. Implies "r". See level for details. "r.conf" adds a confidence interval around the "r" line. This concerns the regression line itself rather than the predictions it makes and is not often of much interest. Implies "r". level applies just like it does for "r.pred". "lqs" adds an lqs resistant regression line. Roughly speaking, this produces approximately the best regression line that is possible if it is allowed to throw the most difficult 50% of the points away. The line is suppressed if there are less than 8 points. "smooth", "loess", "lowess" are all synonymous and add a locally weighted regression via panel.loess, whose configuration parameters will be passed to the call if given. The line is suppressed if there are less than 8 points. "ab" adds an arbitrary line (described by parameters a= and b=) via panel.ab. This does currently not work due to parameter name clashes. "rug" adds a rug plot via panel.rug. "cor" prints the correlation coefficient computed by cor in the lower right corner of the plot. "N" prints the number of non-NA data points in the lower right corner of the plot. "v" (verbose) prints various statistics regarding the plot to the console.

r.min

Even if type "r" is requested, the regression line will appear only if abs(cor(x,y) >= r.min).

level

The confidence level of the intervals plotted by type "r.conf" and type "r.pred".

unicolor

The colors used for the lines drawn by types "r", "r.pred", "r.conf", "loess" are normally taken from trellis.par.get("regression.line") (as introduced by a.resetplotparams). However, if you use xyplot with panel=panel.superpose, panel.groups=panel.xy, you must specify unicolor=T. The regression lines will then be plotted in the style given by trellis.par.get("superpose.line") according to the respective group.

...

Further parameters as needed for instance by panel.loess and lqs.

Details

The types "p", "l", "b", "o", "h", "s", "S" are in fact processed by panel.xyplot. Specifying col, lty, lwd will not work, as there are calls that include both ... and some of these.

Author(s)

Lutz Prechelt, prechelt@inf.fu-berlin.de

See Also

a.resetplotparams, trellis.par.get, panel.xyplot, panel.superpose, panel.loess, lm, lqs.

Examples

1
2
3
4
5
6
7
8
# set  grid.prompt(TRUE)  to see each plot separately (click graphics window)
data(iris)
a.resetplotparams()
print(xyplot(Sepal.Width ~ Sepal.Length|Species, data=iris,
             panel=panel.xy, type="p,grid,v,lqs,r.pred,loess"))
print(xyplot(Sepal.Width ~ Sepal.Length, data=iris, groups=Species,
             panel=panel.superpose, panel.groups=panel.xy,
             type=c("p","grid","v","loess"), unicolor=TRUE))

prechelt/agsemisc documentation built on May 25, 2019, 11:26 a.m.