curve3D: An analogue to curve() for functions of two variables.

Description Usage Arguments Value Examples

View source: R/curve3D.R

Description

An analogue to curve() for functions of two variables. Functions can be visualized using heatmaps or 3D surfaces.

Usage

1
curve3D(f, from.x = 0, to.x = 1, from.y = 0, to.y = 1, heatmap = FALSE, n = 101)

Arguments

f

Function to visualize. Must expect arguments named 'x' and 'y'.

from.x

Minimal value of 'x'.

to.x

Maximal value of 'x'.

from.y

Minimal value of 'y'.

to.y

Maximal value of 'y'.

heatmap

Boolean indicates whether or not to visualize function using a 3D surface or a heatmap. Defaults to FALSE.

n

How many points should f be evaluated at along each dimension?

Value

None. Called for side effects.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
library('curve3D')

g <- function(x, y) {(1 + y * 2) ^ (-x / y) * (1 + y * 1) ^ (x / y)}

curve3D(g, from.x = 0.01, to.x = 1, from.y = 0.01, to.y = 1, heatmap = FALSE)
curve3D(g, from.x = 0.01, to.x = 1, from.y = 0.01, to.y = 1, heatmap = TRUE)

h <- function(x, y) {x ^ 2 + y ^ 2}

curve3D(h, from.x = 0.01, to.x = 1, from.y = 0.01, to.y = 1, heatmap = FALSE)
curve3D(h, from.x = 0.01, to.x = 1, from.y = 0.01, to.y = 1, heatmap = TRUE)

i <- function(x, y) {sin(x) + sin(y)}

curve3D(i, from.x = 1, to.x = 10, from.y = 1, to.y = 10, heatmap = FALSE)
curve3D(i, from.x = 1, to.x = 10, from.y = 1, to.y = 10, heatmap = TRUE)

j <- function(x, y) {x + y + x * y}

curve3D(j, from.x = 1, to.x = 10, from.y = 1, to.y = 10, heatmap = FALSE)
curve3D(j, from.x = 1, to.x = 10, from.y = 1, to.y = 10, heatmap = TRUE)

johnmyleswhite/curve3D documentation built on May 19, 2019, 5:17 p.m.