Skip to contents

Fits are computed explicitly before drawing. Supply predictions from any model on a rectangular grid; fitted R objects and callbacks are not stored in the drawing. The prediction grid may extend the original axis ranges. Add surfaces before composing drawings with draw_panels().

Usage

draw_add_surface(
  plot,
  x = NULL,
  y = NULL,
  z = NULL,
  name = "Surface",
  color = "#6ca3a0",
  opacity = 0.35,
  layer = NULL,
  expand = TRUE
)

Arguments

plot

htmlwidget: Existing Cartesian ECharts-GL drawing.

x, y

Numeric: Finite, distinct grid coordinates, at least two per axis.

z

Numeric matrix: Predictions, with x along rows and y along columns. NA removes adjacent cells. At least one complete grid cell is required.

name

Character: Legend label; matching names link legend selection.

color

Character: Surface fill color.

opacity

Numeric [0, 1]: Surface opacity.

layer

Optional SurfaceLayer: Complete geometry, supplied alone.

expand

Logical: Extend axis ranges to include surface coordinates. When false, all finite surface coordinates must already lie within them.

Value

htmlwidget: Drawing with native interactive and vector surface layers.

Examples

x <- y <- seq(-1, 1, length.out = 5)
draw_add_surface(draw_scatter3d(c(-1, 1), c(-1, 1), c(-1, 1)),
  x, y, outer(x, y, `+`), name = "Predicted")