vc_plot_gradient: Plot a gradient with optional stored directional playback

View source: R/plot_multivariable.R

vc_plot_gradientR Documentation

Plot a gradient with optional stored directional playback

Description

Plot a gradient with optional stored directional playback

Usage

vc_plot_gradient(
  result,
  f,
  directions = NULL,
  xlim = NULL,
  ylim = NULL,
  n = 61L,
  vector_scale = 1,
  colors = c(field = "#24476b", gradient = "#c44736", direction = "#188367", point =
    "#222222"),
  alpha = 0.6,
  line_width = 3,
  animate = TRUE,
  frame_ms = 400,
  title = NULL,
  scene = list(aspectmode = "data")
)

Arguments

result

Result from vc_gradient(), in dimension two or three.

f

Deterministic scalar field accepting ONE numeric vector and returning one finite real scalar. For f(x,y), supply an explicit wrapper function(v)f(v[1],v[2]); no automatic signature guessing is performed.

directions

Optional list of vc_directional results at the same point. Playback uses those stored unit directions/estimates; none are computed.

xlim, ylim

Optional finite increasing contour bounds covering the point. NULL covers the displayed gradient endpoint and unit directions. Used only in dimension two.

n

Integer number of contour samples per coordinate, at least two.

vector_scale

Positive finite display multiplier on the gradient vector. Hover retains the unscaled estimate. Unit directions have unit display length.

colors

Named field, gradient, direction and point Plotly/CSS colors.

alpha

Finite contour opacity between zero and one.

line_width

Positive finite vector line width.

animate

Logical; multiple stored directions get playback and slider. FALSE shows the last direction; a single direction remains static.

frame_ms

Positive finite frame duration in milliseconds.

title

Optional scalar title; default reports numerical sensitivity.

scene

Plotly scene list for the three-dimensional vector view.

Details

Recovers the original gradient_scalar vector and gradient_direction2d directional playback representations. Vectors are drawn in the domain; endpoints/hover identify direction and magnitude. A zero numerical gradient is not assigned an arbitrary preferred direction. No maximum/minimum or differentiability assertion follows from the arrows. Invalid contour evaluations are gaps, and axis aspect ratios preserve data proportions.

Value

Plotly widget: sampled contours plus gradient in dimension two, or gradient/point in three-dimensional domain coordinates. In 3D the scalar field itself is not drawn as an asserted four-dimensional surface.

Examples

if(requireNamespace("plotly",quietly=TRUE)) {
  f <- function(v)v[1]^2+2*v[2]^2
  f |> vc_gradient(c(1,1)) |> vc_plot_gradient(f=f)
}

vectorialcalculus documentation built on Nov. 17, 2026, 1:09 a.m.