Usage
panel_reg(
x,
y,
col = par("col"),
bg = par("bg"),
pch = par("pch"),
cex = par("cex"),
lwd = par("lwd"),
line.reg = lm,
line.col = "red",
line.lwd = lwd,
untf = TRUE,
...
)
panel.reg(
x,
y,
col = par("col"),
bg = par("bg"),
pch = par("pch"),
cex = par("cex"),
lwd = par("lwd"),
line.reg = lm,
line.col = "red",
line.lwd = lwd,
untf = TRUE,
...
)
panel_ellipse(
x,
y,
col = par("col"),
bg = par("bg"),
pch = par("pch"),
cex = par("cex"),
el.level = 0.7,
el.col = "cornsilk",
el.border = "red",
major = TRUE,
...
)
panel.ellipse(
x,
y,
col = par("col"),
bg = par("bg"),
pch = par("pch"),
cex = par("cex"),
el.level = 0.7,
el.col = "cornsilk",
el.border = "red",
major = TRUE,
...
)
panel_cor(
x,
y,
use = "everything",
method = c("pearson", "kendall", "spearman"),
alternative = c("two.sided", "less", "greater"),
digits = 2,
prefix = "",
cex = par("cex"),
cor.cex = cex,
stars.col = "red",
...
)
panel.cor(
x,
y,
use = "everything",
method = c("pearson", "kendall", "spearman"),
alternative = c("two.sided", "less", "greater"),
digits = 2,
prefix = "",
cex = par("cex"),
cor.cex = cex,
stars.col = "red",
...
)
panel_smooth(
x,
y,
col = par("col"),
bg = NA,
pch = par("pch"),
cex = 1,
col.smooth = 2,
span = 2/3,
iter = 3,
...
)
Arguments
- x
A numeric vector.
- y
A numeric vector of same length as
x
.- col
The color of the points.
- bg
The background color for symbol used for the points.
- pch
The symbol used for the points.
- cex
The expansion factor used for the points.
- lwd
The line width.
- line.reg
A function that calculates coefficients of a straight line, for instance,
lm()
, orrlm()
for robust linear regression.- line.col
The color of the line.
- line.lwd
The width of the line.
- untf
Logical asking whether to untransform the straight line in case one or both axis are in log scale.
- ...
Further arguments to plot functions.
- el.level
The confidence level for the bivariate normal ellipse around data; the default value of 0.7 draws an ellipse of roughly +/-1 sd.
- el.col
The color used to fill the ellipse.
- el.border
The color used to draw the border of the ellipse and the standardized major axis.
- major
If
TRUE
, the standardized major axis is also drawn.- use
One of
"everything"
,"all.obs"
,"complete.obs"
,"na.or.complete"
, or"pairwise.complete.obs"
(can be abbreviated). Defines how thecor()
function behaves with missing observations.- method
One of the three correlation coefficients
"pearson"
(default),"kendall"
, or"spearman"
. Can be abbreviated.- alternative
The alternative hypothesis in correlation test, see
cor.test()
.- digits
The number of decimal digits to print when the correlation coefficient is printed in the graph.
- prefix
A prefix (character string) to use before the correlation coefficient printed in the graph.
- cor.cex
Expansion coefficient for text in printing correlation coefficients.
- stars.col
The color used for significance stars (with: *** p < 0.001, ** p < 0.1, * p < 0.05, . p < 0.1.
- col.smooth
Color to be used by lines for drawing the smooths.
- span
Smoothing parameter
f
forlowess()
, see there.- iter
Number of robustness iterations for
lowess()
.
Value
These functions return nothing and are used for their side effect of plotting in panels of composite plots.
Details
Theses functions should be used outside of the diagonal in
pairs()
, or with coplot()
, as they are bivariate plots.
See also
coplot()
, pairs()
, panel.smooth()
, lm()
, ellipse()
,
cor()
and cor.test()
Author
Philippe Grosjean phgrosjean@sciviews.org, but code inspired from
panel.smooth()
in graphics and panel.car()
in package car.
Examples
# Smooth lines in lower graphs and straight lines in upper graphs
pairs(trees, lower.panel = panel_smooth, upper.panel = panel_reg)
# Robust regression lines
library(MASS) # For rlm()
pairs(trees, panel = panel_reg, diag.panel = panel_boxplot,
reg.line = rlm, line.col = "blue", line.lwd = 2)
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
#> Warning: "reg.line" is not a graphical parameter
#> Warning: "line.col" is not a graphical parameter
#> Warning: "line.lwd" is not a graphical parameter
# A Double log graph
pairs(trees, lower.panel = panel_smooth, upper.panel = panel_reg, log = "xy")
# Graph suitables to explore correlations (take care there are potentially
# many simultaneous tests done here... So, you loose much power in the whole
# analysis... use it just as an indication!)
# Pearson's r
pairs(trees, lower.panel = panel_ellipse, upper.panel = panel_cor)
#> Warning: argument 1 does not name a graphical parameter
#> Warning: argument 1 does not name a graphical parameter
#> Warning: argument 1 does not name a graphical parameter
# Spearman's rho (ellipse and straight lines not suitable here!)
pairs(trees, lower.panel = panel_smooth, upper.panel = panel_cor,
method = "spearman", span = 1)
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: Cannot compute exact p-value with ties
#> Warning: "span" is not a graphical parameter
#> Warning: argument 1 does not name a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: Cannot compute exact p-value with ties
#> Warning: "span" is not a graphical parameter
#> Warning: argument 1 does not name a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: Cannot compute exact p-value with ties
#> Warning: "span" is not a graphical parameter
#> Warning: argument 1 does not name a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
# Several groups (visualize how bad it is to consider the whole set at once!)
pairs(iris[, -5], lower.panel = panel_smooth, upper.panel = panel_cor,
method = "kendall", span = 1,
col = c("red3", "blue3", "green3")[iris$Species])
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: argument 1 does not name a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: argument 1 does not name a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: argument 1 does not name a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: argument 1 does not name a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: argument 1 does not name a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: argument 1 does not name a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
#> Warning: "method" is not a graphical parameter
#> Warning: "span" is not a graphical parameter
# Now analyze correlation for one species only
pairs(iris[iris$Species == "virginica", -5], lower.panel = panel_ellipse,
upper.panel = panel_cor)
#> Warning: argument 1 does not name a graphical parameter
#> Warning: argument 1 does not name a graphical parameter
#> Warning: argument 1 does not name a graphical parameter
#> Warning: argument 1 does not name a graphical parameter
#> Warning: argument 1 does not name a graphical parameter
#> Warning: argument 1 does not name a graphical parameter
# A coplot with custom panes
coplot(Petal.Length ~ Sepal.Length | Species, data = iris,
panel = panel_ellipse)