R: Plot a 3D surface representing a 2D curve

curve3d {emdbook} | R Documentation

## Plot a 3D surface representing a 2D curve

### Description

Two-dimensional analogue of `curve`: generates a surface and plots it

### Usage

    curve3d(expr, from = c(0, 0), to = c(1, 1), n = c(41, 41),
    xlim, ylim, add = FALSE,
    xlab=varnames[1],
    ylab=varnames[2],
    zlab = NULL, log = NULL, sys3d = c("persp", "wireframe", "rgl",
    "contour", "image", "none"),
    varnames=c("x","y"),use_plyr=TRUE,.progress="none",...)

### Arguments

`expr` | a mathematical expression using `x` and `y` as the independent variables
`from` | minimum values for `x` and `y`
`to` | maximum values for `x` and `y`
`xlim` | range of values for `x`
`ylim` | range of values for `y`
`n` | number of grid points in each direction
`add` | (logical) add to an existing plot? (only possible for contour plots or rgl)
`xlab` | x label
`ylab` | y label
`zlab` | z label
`log` | (character): `"x"`, `"y"`, or `"xy"` for logarithmic axes
`sys3d` | 3D plotting system to use: one of `"persp"`, `"wireframe"`, `"rgl"`, `"contour"`, `"image"`, or `"none"`
`varnames` | names of variables to substitute
`use_plyr` | use methods from the `plyr` package?
`.progress` | progress bar type (`"none"`, `"text"`, `"tk"`,`"win"`: see `create_progress_bar`)
`...` | additional arguments to the plotting functions

### Value

invisibly, a list of

`x` | x values
`y` | y values
`z` | z matrix

### Note

You must explicitly install the `rgl` package (via `install.packages("rgl")`) before using `sys3d="persp"`.

### Author(s)

Ben Bolker

### See Also

`outer`, `curve`

### Examples

    curve3d(cos(2*pi*x)+sin(2*pi*y/3),
     from=c(0,0),to=c(1,1))
    x <- 1
    y <- 3
    curve3d(cos(2*pi*x)+sin(2*pi*y/3),
     from=c(0,0),to=c(1,1),sys3d="wireframe")
    curve3d(x*cos(2*pi*a/x)+sin(2*pi*b/y),
     from=c(0,0),to=c(1,1),sys3d="wireframe",
    varnames=c("a","b"))  ## identical
    par(mfrow=c(2,2))
    curve3d(cos(2*pi*x)+sin(2*pi*y/3),
     from=c(0,0),to=c(1,1),sys3d="image")
    curve3d(x*cos(2*pi*a/x)+sin(2*pi*b/y),
     from=c(0,0),to=c(1,1),sys3d="image",
    varnames=c("a","b"))  ## identical
    x <- 4
    curve3d(cos(2*pi*a/x)+y*sin(2*pi*b/y),
     from=c(0,0),to=c(1,1),sys3d="image",
    varnames=c("a","b"))
    curve3d(cos(2*pi*x)+sin(2*pi*y/3),
     from=c(0,0),to=c(1,1),sys3d="image")
    curve3d(cos(2*pi*x)+sin(2*pi*y/3),
     sys3d="contour",add=TRUE)

[Package emdbook version 1.3.9 Index]