plotSurface2D: Contour plot of a 2D surface

View source: R/auxiliary.R

plotSurface2DR Documentation

Contour plot of a 2D surface

Description

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

Usage

plotSurface2D(x = seq_len(nrow(z)), y = seq_len(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


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. 21, 2023, 1:08 a.m.