Learn R Programming

pracma (version 1.7.9)

ezcontour,ezmesh: Contour and Mesh Plotter

Description

Easy-to-use contour and 3-D mesh plotter.

Usage

ezcontour(f, xlim = c(-pi,pi), ylim = c(-pi,pi), 
             n = 60, filled = FALSE, col = NULL)

ezmesh(f, xlim = c(-pi,pi), ylim = c(-pi,pi), n = 60, col = "lightgray", ...)

Arguments

f
2-D function to be plotted, must accept (x,y) as a vector.
xlim, ylim
defines x- and y-ranges as intervals.
n
number of grid points in each direction.
col
colour of isolines lines, resp. the surface color.
filled
logical; shall the contour plot be
...
parameters to be passed to the persp function.

Value

  • Plots the function graph and invisibly returns NULL.

Details

ezcontour generates a contour plot of the function f using contour (and image if filled=TRUE is chosen). If filled=TRUE is chosen, col should be a color scheme, the default is heat.colors(12).

ezmesh generates a mesh/surface plot of the function f using persp. The most important additional parameters to be passed in ... are and .

The function f needs not be vectorized in any form.

See Also

contour, image, persp

Examples

Run this code
f <- function(xy) {
    x <- xy[1]; y <- xy[2]
    3*(1-x)^2 * exp(-(x^2) - (y+1)^2) -
        10*(x/5 - x^3 - y^5) * exp(-x^2 - y^2) -
        1/3 * exp(-(x+1)^2 - y^2)
    }
ezcontour(f, col = "navy")
ezcontour(f, filled = TRUE)
ezmesh(f)
ezmesh(f, col="lightblue", theta = -15, phi = 30)

Run the code above in your browser using DataLab