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,
...
)
A numeric vector.
A numeric vector of same length as x
.
The color of the points.
The background color for symbol used for the points.
The symbol used for the points.
The expansion factor used for the points.
The line width.
A function that calculates coefficients of a straight line,
for instance, lm()
, or rlm()
for robust linear regression.
The color of the line.
The width of the line.
Logical asking whether to untransform the straight line in case one or both axis are in log scale.
Further arguments to plot functions.
The confidence level for the bivariate normal ellipse around data; the default value of 0.7 draws an ellipse of roughly +/-1 sd.
The color used to fill the ellipse.
The color used to draw the border of the ellipse and the standardized major axis.
If TRUE
, the standardized major axis is also drawn.
One of "everything"
, "all.obs"
, "complete.obs"
,
"na.or.complete"
, or "pairwise.complete.obs"
(can be abbreviated).
Defines how the cor()
function behaves with missing observations.
One of the three correlation coefficients "pearson"
(default), "kendall"
, or "spearman"
. Can be abbreviated.
The alternative hypothesis in correlation test, see
cor.test()
.
The number of decimal digits to print when the correlation coefficient is printed in the graph.
A prefix (character string) to use before the correlation coefficient printed in the graph.
Expansion coefficient for text in printing correlation coefficients.
The color used for significance stars (with: *** p < 0.001, ** p < 0.1, * p < 0.05, . p < 0.1.
Color to be used by lines for drawing the smooths.
Smoothing parameter f
for lowess()
, see there.
Number of robustness iterations for lowess()
.
These functions return nothing and are used for their side effect of plotting in panels of composite plots.
Theses functions should be used outside of the diagonal in
pairs()
, or with coplot()
, as they are bivariate plots.
coplot()
, pairs()
, panel.smooth()
, lm()
, ellipse()
,
cor()
and cor.test()
# 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)