mplot3
: XY Scatter and line plotsPlot points and lines with optional fits and standard error bands
mplot3.xy(x, y, fit = NULL, formula = NULL, se.fit = FALSE,
mod.params = NULL, error.x = NULL, error.y = NULL,
cluster = NULL, cluster.params = list(), data = NULL,
type = NULL, group = NULL, xlab = NULL, ylab = NULL,
main = NULL, main.line = 0.5, main.adj = 0, main.col = NULL,
main.font = 2, main.family = "", cex = 1.2, xlim = NULL,
ylim = NULL, xpd = TRUE, xaxs = "r", yaxs = "r", rsq = NULL,
rsq.pval = FALSE, rsq.side = 1, rsq.adj = 0.98,
rsq.padj.shift = 0, rsq.col = NULL, fit.error = FALSE,
fit.error.side = 1, fit.error.padj = NA, fit.error.col = NULL,
xaxp = NULL, yaxp = NULL, scatter = TRUE, axes = TRUE,
axes.equal = FALSE, axes.col = NULL, pty = "s", box = NULL,
bty = "o", box.col = NULL, box.alpha = 1, box.lty = 1,
box.lwd = 1.5, grid = FALSE, grid.nx = NULL, grid.ny = NULL,
grid.col = NULL, grid.alpha = 1, grid.lty = 1, grid.lwd = 1.5,
bg = NULL, plot.bg = NULL, annotation = NULL,
annotation.col = NULL, tick.col = NULL, tck = 0.015,
x.axis.side = 1, y.axis.side = 2, x.axis.at = NULL,
y.axis.at = NULL, x.axis.labs = TRUE, y.axis.labs = TRUE,
x.axis.padj = -1.1, xlab.line = 1.3, y.axis.padj = 0.9,
ylab.line = 1.6, xlab.adj = 0.5, ylab.adj = 0.5, mar = c(2.5,
2.5, 1.5, 1), col = NULL, pch = ifelse(is.null(point.bg.col), 16,
21), point.cex = 0.85, point.col = NULL, point.bg.col = NULL,
point.alpha = 0.66, line.col = NULL, line.alpha = 0.66, lty = 1,
lwd = 2, marker.col = NULL, marker.alpha = 0.66,
error.x.col = NULL, error.y.col = NULL, error.x.lty = 1,
error.y.lty = 1, error.x.lwd = 1, error.y.lwd = 1,
error.arrow.code = 3, fit.col = NULL, fit.lwd = 2.5,
fit.alpha = 0.66, fit.legend = ifelse(is.null(fit), FALSE, TRUE),
se.lty = "poly", se.lwd = 1, se.col = NULL, se.alpha = 0.5,
se.times = 2, se.border = FALSE, se.density = NULL,
xy.fit = NULL, xy.fit.col = NULL, firstpc = FALSE,
firstpc.lty = 3, firstpc.col = NULL, hline = NULL,
hline.col = NULL, hline.lwd = 1.5, hline.lty = 3, vline = NULL,
vline.lwd = 1.5, vline.col = "blue", vline.lty = 3,
diagonal = FALSE, diagonal.inv = FALSE, diagonal.lwd = 1.5,
diagonal.lty = 1, diagonal.col = NULL, diagonal.alpha = 0.5,
group.legend = NULL, group.title = NULL, group.names = NULL,
group.side = 3, group.adj = 0.02, group.padj = 2, group.at = NA,
fit.legend.col = NULL, fit.legend.side = 3, fit.legend.adj = 0.02,
fit.legend.padj = 2, fit.legend.at = NA, labs.col = NULL,
na.rm = TRUE, theme = getOption("rt.theme", "lightgrid"),
palette = getOption("rt.palette", "rtCol1"), zero.lines = NULL,
zero.col = NULL, zero.alpha = 1, zero.lty = 1, zero.lwd = 1.5,
order.on.x = NULL, alpha.off = FALSE, autolabel = letters,
new = FALSE, set.par = TRUE, par.reset = TRUE,
return.lims = FALSE, pdf.width = 6, pdf.height = 6,
verbose = FALSE, filename = NULL, ...)
Numeric vector or list of vectors for x-axis.
If data
is provided, name of variable, unquoted.
Numeric vector of list of vectors for y-axis
If data
is provided, name of variable, unquoted.
String: rtemis model to calculate y ~ x fit. Options: see modSelect
Can also be Logical, which will give a GAM fit if TRUE. If you specify "NLA", the activation function should
be passed as a string.
Formula: Provide a formula to be solved using s.NLS. If provided, fit
is
forced to 'nls'
. e.g. y ~ b * m ^ x for a power curve. Note: nls
is prone to errors
and warnings, but is powerful. Use single letters for parameter names, no numbers.
Logical: If TRUE, draw the standard error of the fit
Vector, float: Error in x
(e.g. standard deviation) will be plotted as bars around point
Vector, float: Error in y
(e.g. standard deviation) will be plotted as bars around point
String: Clusterer name. Will cluster data.frame(x, y)
and
pass result to group
. Run clustSelect for options
List: Names list of parameters to pass to the cluster
function
(Optional) data frame, where x
and y
are defined
String: "p" for points, "l" for lines, "s" for steps. Default = "p". If x
and/or y
contains multiple
vectors, type
can be a vector, e.g. c("p", "l", "l")
will give a set of points and two sets
of lines. Otherwise, type
is recycled to length of x
Vector: will be converted to factor.
If data
is provided, name of variable, unquoted.
String: x-axis label
String: y-axis label
String: Plot title
Float: mtext line
argument for the title. Higher numbers move title upwards.
Default = .5
Float: Plot title alignment (0 = left, .5 = center, 1 = right)
Color for title. Defaults to black for theme "light" and "box", otherwise white
Integer: 1: regular, 2: bold, 3: italic. See par("font")
for more
String: Font family to use. See par("family")
Float: Character expansion factor (See ?par
)
Float vector, length 2: x-axis limits
Float vector, length 2: y-axis limits
Logical: If TRUE, add legend with R-squared (if fit is not NULL)
Logical: If TRUE, add legend with R-squared and its p-value (if fit is not NULL)
Logical: Should the axes be drawn? Defaults to TRUE
Logical: Should axes be equal? Defaults to FALSE
String: Color for axes values (box color set with box.col
)
"s" gives a square plot, "m" gives a plot that fills graphics device size. Defaults to "s"
(See ?par
)
Logical: Should a box be drawn around the plot? Defaults to TRUE for themes "box" and "darkbox"
Character: "o", "l", "7", "c", "u", or "]" result in a box resembling each character.
(See ?par
)
Box color
Alpha for box.col
Box line type
Logical: Should grid be drawn?
Integer: N of grid lines on the x axis.
Use with caution, probably along with xaxs = "i"
Integer: N of grid lines on the y axis
Use with caution, probably along with yaxs = "i"
Grid color
Alpha for grid.col
Grid line type (See ?par("lty")
)
Grid line width
Background color. Defaults to white for themes "light" and "box", black otherwise.
String: Add annotation at the bottom right of the plot
Color for annotation
Float: Tick length. Can be negative (See ?par("tck")
)
Adjustment for the x axis tick labels position
Adjustment for the x axis label position (See codeline in ?mtext
)
Similar to x.axis.padj
for the y axis
Similar to xlab.line
for the y axis
adj
for xlab
(See ?par
)
adj
for ylab
(See ?par
)
Vector, length 4: Margins; see mar
in ?par
Fit line width
How to draw the se.fit
"poly" draws a polygon around the fit line,
otherwise an integer defines the lty (line type) for lines to be drawn
Color for se.fit
Alpha for se.fit
Draw polygon or lines at +/- se.times
* standard error of fit. Defaults to 2
(1.96 * standard error corresponds to 95% confidence interval)
Define border of polygon for se.fit
.
See border
in graphics::polygon
Density of shading line of polygon for se.fit
.
See density
in graphics::polygon
Logical: If TRUE, place group.names
in a legend
String: Group title, shown above group names. e.g. if group names are
c("San Francisco", "Philadelphia"), group.title
can be "Place of residence"
(Optional) If multiple groups are plotted, use these names if group.title = TRUE
String: "light", "dark", "lightgrid", "darkgrid", "lightbox", "darkbox"
Default = "lightgrid" if no default "rt.fit"
is set using options
.
You can set a system-wide default in your .Rprofile
by including a line like
options(rt.theme = 'lightgrid')
Logical: If TRUE, draw lines at x = 0 and y = 0
Color for zero.lines
Color alpha for zero.lines
Zero line line type
Zero line width
Logical: If TRUE, add plot to existing plot. See par("new")
Additional arguments to be passed to learner function
Box line width
This is relatively old code and may need a little cleaning up