plotSurface3D: Visualization of a 3D surface

View source: R/auxiliary.R

plotSurface3DR Documentation

Visualization of a 3D surface

Description

Convenient wrapper for visualizing a real function of three variables by means of a colour scale and alpha shading.

Usage

plotSurface3D(x = seq_len(nrow(t)), y = seq_len(ncol(t)),
  z = seq_len(dim(t)[3]), f, t = NULL, nLev = 20, levels = NULL,
  fVect = FALSE, size = 15, alpha = 0.05, ...)

Arguments

x, y, z

numerical grids for each dimension.

f

function to be plot. Must take a single argument (see examples).

t

a vector of length length(x) * length(y) * length(z) containing the evaluation of f in the trivariate grid. If not provided, it is computed internally.

nLev

number of levels in the colour scale.

levels

vector of breaks in the colour scale. If not provided, it is set to quantile(z, probs = seq(0, 1, l = nLev)).

fVect

flag to indicate whether f is a vectorized function (see examples).

size

size of points in pixels.

alpha

alpha value between 0 (fully transparent) and 1 (opaque).

...

further arguments passed to plot3d

Value

The vector t, invisible.

Examples


if (requireNamespace("rgl")) {
  x <- seq(-pi, pi, l = 50)
  f <- function(x) 10 * (sin(x[, 1]) * cos(x[, 2]) - sin(x[, 3]))^2
  t <- plotSurface3D(x, x, x, size = 10, alpha = 0.01, fVect = TRUE, f = f)
  plotSurface3D(x, x, x, t = t, size = 15, alpha = 0.1,
                levels = quantile(t, probs = seq(0, 0.1, l = 20)))
}


sdetorus documentation built on Aug. 21, 2023, 1:08 a.m.