View source: R/plot_integral.R
| vc_plot_integral | R Documentation |
Visualize signed numerical quadrature
vc_plot_integral(
result,
f,
n = 401L,
colors = c(curve = "#24476b", approximation = "#188367", nodes = "#c44736"),
alpha = 0.3,
line_width = 2,
title = NULL,
xlab = "x",
ylab = "f(x)",
xscale = c("linear", "log"),
yscale = c("linear", "log")
)
result |
Result of vc_integrate(). |
f |
The same deterministic scalar function used for the calculation. Function values at the stored anchor points must match the result. |
n |
Integer number of curve samples, at least 2. The curve is a sampled visualization, not an exact representation or a continuity test. |
colors |
Named curve, approximation and nodes Plotly/CSS colors. |
alpha |
Finite fill opacity between zero and one. |
line_width |
Positive finite curve/approximation line width. |
title |
Optional scalar plot title. NULL uses a descriptive default. |
xlab, ylab |
Scalar axis labels. |
xscale, yscale |
Plotly axis scale: linear or log. Log scales may hide nonpositive data and cannot faithfully show signed areas across zero. |
Plotting never recomputes quadrature. Stored node values are checked against f. Simpson arcs interpolate each consecutive pair of cells. Fill represents a signed-integral region, not an unsigned area calculation. A reversed orientation changes the integral sign without changing f. Hover reports the stored estimate, diagnostic and orientation. Sampled curves/fills can miss features and do not establish integrability.
Plotly widget. Fixed rules show finest stored nodes and piecewise linear/parabolic interpolation with fill to zero. Adaptive results show only a sampled function with fill to zero, not QUADPACK's internal mesh.
if(requireNamespace("plotly",quietly=TRUE)) {
f <- function(x)x^2
f |> vc_integrate(c(0,2),method="simpson",n=4) |> vc_plot_integral(f=f)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.