plotSurface2D: Contour plot of a 2D surface

Description Usage Arguments Value Examples

View source: R/auxiliary.R

Description

Convenient wrapper for plotting a contour plot of a real function of two variables.

Usage

1
2
plotSurface2D(x = 1:nrow(z), y = 1:ncol(z), f, z = NULL, nLev = 20,
  levels = NULL, fVect = FALSE, ...)

Arguments

x, y

numerical grids fore each dimension. They must be in ascending order.

f

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

z

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

nLev

the number of levels the range of z will be divided into.

levels

vector of contour levels. 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).

...

further arguments passed to image

Value

The matrix z, invisible.

Examples

1
2
3
4
grid <- seq(-pi, pi, l = 100)
plotSurface2D(grid, grid, f = function(x) sin(x[1]) * cos(x[2]), nLev = 20)
plotSurface2D(grid, grid, f = function(x) sin(x[, 1]) * cos(x[, 2]),
              levels = seq(-1, 1, l = 10), fVect = TRUE)

sdetorus documentation built on Aug. 19, 2021, 9:06 a.m.