The seam between convenient input and a complete, validated object: pass the
handful of things you care about, get back a ScatterConfig with everything
else at its default.
Usage
setup_ScatterConfig(
x = NULL,
y = NULL,
size = NULL,
group = NULL,
fit = NULL,
se = TRUE,
n_fit = 200L,
fit_alpha = 0.25,
palette = NULL,
pad = DEFAULT_PAD,
square = FALSE,
equal_axes = FALSE,
xlim = NULL,
ylim = NULL,
xlab = NULL,
ylab = NULL,
title = NULL,
margin_top = NULL,
margin_right = NULL,
margin_bottom = NULL,
margin_left = NULL,
dat_path = NULL,
origin = NULL,
writer = NULL,
se_times = 1.96,
rsq = FALSE,
diagonal = FALSE,
diagonal_color = NULL,
legend_position = "top",
legend_placement = "outside",
fit_name = NULL,
rug = FALSE,
hover = NULL
)Arguments
- x, y
Optional Character: Columns drawn on each axis.
- size
Optional Character: Column giving per-point size.
- group
Optional Character: Column to group and color points by.
- fit
Optional Character {"glm", "gam"}: Fit to overlay.
NULLdraws no fit.- se
Logical: If TRUE, shade the fit standard-error band.
- n_fit
Integer
[2, Inf): Points used to draw the fit line.- fit_alpha
Numeric
[0, 1]: Opacity of the standard-error band.- palette
Optional Character: Series colors, overriding the theme palette for this chart.
NULLuses the theme's.- pad
Numeric
[0, Inf): Fraction of the data range to extend each axis by whenxlim/ylimare not given. The default matches base R'sxaxs = "r", which extends the range by 4% at each end.- square
Logical: If TRUE, draw the plotting box square – equal height and width in pixels, excluding axis labels and margins.
- equal_axes
Logical: If TRUE, give one data unit the same size in pixels on both axes. Set with
squarefor a plot that is both, such as a true-versus-predicted plot whose identity line runs at 45 degrees; the two axes are then made to span the same interval.- xlim, ylim
Optional Numeric: Axis limits, length 2.
NULLderives them from the data, padded bypad.- xlab, ylab
Optional Character: Axis labels.
NULLderives them from the data.- title
Optional Character: Chart title. Declared here because it is the one property every chart type has;
paletteis not (four take acolormapinstead), and axis labels and margins are cartesian-only.- margin_top, margin_right, margin_bottom, margin_left
Optional Integer
[0, Inf): Plot margins in pixels.- dat_path
Optional Character: Path to the data, read at draw time. The serializable alternative to passing
datatodraw().- origin
Optional Named character: Where each value came from. Normally computed from which arguments were supplied; pass it only when restoring a config that already carries provenance.
- writer
Optional Named character: Which interface wrote the config, as
nameandversion.- se_times
Numeric
[0, Inf): Multiplier for the fitted standard error.- rsq
Logical: Include the fitted model's R-squared in series labels.
- diagonal
Logical: Draw the identity line within the axis limits.
- diagonal_color
Optional Character: Identity-line color.
- legend_position
Character {"top", "bottom", "left", "right", "top-left", "top-right", "bottom-left", "bottom-right"}: Legend anchor. Top/bottom anchors use horizontal rows; left/right anchors use a vertical column. Corner anchors align within the top or bottom row.
- legend_placement
Character {"outside", "inside"}: Relation to the plotting area. Outside placement reserves space for the complete legend; inside placement overlays the data. Neither setting adds a missing legend.
- fit_name
Optional Character: Label for fitted layers.
- rug
Logical: Show marginal marks along the x and y axes.
- hover
Optional Character: Column containing per-observation tooltip labels.
Value
ScatterConfig object.
Details
Every argument is optional, which is what lets the published schema
require nothing: an authored config is a subset of the full set, and the
interface fills in the rest. This is a different entry point from
draw_scatter(), which takes vectors and keeps its mandatory x and y.
Examples
cfg <- setup_ScatterConfig(x = "wt", y = "mpg", fit = "glm", title = "Cars")
draw(cfg, data = mtcars)