Skip to contents

Quick scatter plot from x/y data with optional fitted line and confidence band.

Usage

draw_scatter(
  x,
  y,
  size = NULL,
  group = NULL,
  fit = NULL,
  se = TRUE,
  fit_alpha = 0.25,
  n_fit = 200,
  color = NULL,
  xlim = NULL,
  ylim = NULL,
  xlab = NULL,
  ylab = NULL,
  title = NULL,
  theme = NULL,
  margins = NULL,
  width = NULL,
  height = NULL,
  filename = NULL
)

Arguments

x

Numeric: X values.

y

Numeric: Y values.

size

Optional Numeric: Symbol sizes.

group

Optional Vector: Grouping variable for multiple series.

fit

Optional Character {"glm", "gam"}: Fit method. NULL disables fitting. "gam" for mgcv::gam(). The fitted line and 95\ are computed per group when group is provided.

se

Logical: Whether to show the confidence band.

fit_alpha

Numeric [0, 1]: Opacity for the confidence-band fill.

n_fit

Numeric [1, Inf): Number of evaluation points for the fit.

color

Optional Character: Series color palette — a single color string or character vector that overrides the theme palette for this chart. When group is set, colors are assigned per group in order. color takes precedence over the theme palette.

xlim

Optional Numeric [length 2]: X-axis limits c(min, max). Defaults to range(x) padded by 4\% of the span on each side.

ylim

Optional Numeric [length 2]: Y-axis limits c(min, max). Defaults to range(y) padded by 4\% of the span on each side.

xlab

Optional Character: X-axis title.

ylab

Optional Character: Y-axis title.

title

Optional Character: Chart title.

theme

Optional Theme: Theme override. The palette inside the theme can be overridden per-chart with the color argument.

margins

Optional Named numeric vector or named list: Plot margins in pixels (or percentage strings) for any of "top", "right", "bottom", "left". Unspecified sides keep echarts' default auto-sizing. See draw_line() for details.

width

Optional Character or Numeric: Widget width.

height

Optional Character or Numeric: Widget height.

filename

Optional Character: If provided, save the widget to this file via save_drawing().

Value

htmlwidget: Widget object.