panels | R Documentation |
Several panel plots that can be used with coplot()
and pairs()
.
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,
...
)
x |
A numeric vector. |
y |
A numeric vector of same length as |
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, |
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 |
use |
One of |
method |
One of the three correlation coefficients |
alternative |
The alternative hypothesis in correlation test, see
|
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 |
iter |
Number of robustness iterations for |
Theses functions should be used outside of the diagonal in
pairs()
, or with coplot()
, as they are bivariate plots.
These functions return nothing and are used for their side effect of plotting in panels of composite plots.
Philippe Grosjean phgrosjean@sciviews.org, but code inspired from
panel.smooth()
in graphics and panel.car()
in package car.
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)
# 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)
# Spearman's rho (ellipse and straight lines not suitable here!)
pairs(trees, lower.panel = panel_smooth, upper.panel = panel_cor,
method = "spearman", span = 1)
# 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])
# Now analyze correlation for one species only
pairs(iris[iris$Species == "virginica", -5], lower.panel = panel_ellipse,
upper.panel = panel_cor)
# A coplot with custom panes
coplot(Petal.Length ~ Sepal.Length | Species, data = iris,
panel = panel_ellipse)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.