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.
panel.xy(x, y, type = "p,r,r.pred,r=,N=,grid", r.min = 0.5, level = 0.8, slope=0.0, intercept=0.0, unicolor = FALSE, ...)
"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.
"abline"
adds an arbitrary line
(described by parameters slope=
and intercept=
)
via panel.abline
.
col, lty and lwd are taken from trellis.par.get("ab.line")
(non-standard extension as introduced by a.resetplotparams
).
"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.
type "r"
is requested, the regression line
will appear only if abs(cor(x,y) >= r.min)
.type "r.conf"
and type "r.pred"
.panel.abline
if type
contains "abline"
."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=TRUE
. The regression lines will then be plotted in the
style given by trellis.par.get("superpose.line")
according to
the respective group. panel.loess
and lqs
."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.
a.resetplotparams
,
trellis.par.get
,
panel.xyplot
,
panel.superpose
,
panel.loess
,
lm
,
lqs
.
# 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))
Run the code above in your browser using DataLab