Learn R Programming

spatstat.geom (version 3.7-3)

contour.im: Contour plot of pixel image

Description

Generates a contour plot of a pixel image.

Usage

# S3 method for im
contour(x, ..., main, axes=FALSE, add=FALSE,
            nlevels=10, levels=NULL, labels=NULL, log=FALSE, 
            col=par("fg"), 
            clipwin=NULL, show.all=!add, do.plot=TRUE)

Arguments

Value

Invisibly, a rectangle (object of class "owin" specifying a rectangle) containing the plotted region.

Details

This is a method for the generic contour function, for objects of the class "im".

An object of class "im" represents a pixel image; see im.object.

This function displays the values of the pixel image x as a contour plot on the current plot device, using equal scales on the \(x\) and \(y\) axes.

The appearance of the plot can be modified using any of the arguments listed in the help for contour.default. Useful ones include:

nlevels

Number of contour levels to plot.

drawlabels

Whether to label the contour lines with text.

col,lty,lwd

Colour, type, and width of contour lines.

See contour.default for a full list of these arguments.

The defaults for any of the abovementioned arguments can be reset using spatstat.options("par.contour").

If log=TRUE, the contour lines will be evenly-spaced on a logarithmic scale, provided the range of pixel values is at least 1.5 orders of magnitude (a ratio of at least 32). Otherwise the levels will be evenly-spaced on the original scale.

If col is a colour map (object of class "colourmap", see colourmap) then the contours will be plotted in different colours as determined by the colour map. The contour at level z will be plotted in the colour col(z) associated with this level in the colour map.

See Also

im.object, plot.im, persp.im

Examples

Run this code
   # an image
   Z <- setcov(owin())
   contour(Z, axes=TRUE)
   contour(Z)

   V <- 100 * Z^2 + 1
   contour(V, log=TRUE, labcex=1)

   co <- colourmap(rainbow(100), range=c(0,1))
   contour(Z, col=co, lwd=2)

Run the code above in your browser using DataLab