plot.grid: Plot a grid object

View source: R/plot.grid.R

plot.gridR Documentation

Plot a grid object

Description

This function plots a grid object. By default it uses a black and white color gradient.

Usage

## S3 method for class 'grid'
plot(x, asp = 1, xlab = "x", ylab = "y",
    min.val = min(x$m, na.rm = TRUE), max.val = max(x$m, na.rm = TRUE),
    add = FALSE, na.col = NA, use.raster = TRUE, interpolate = FALSE, col,
    nramp=200, reverse.col=FALSE, restore.par = TRUE, ..., use.old)

Arguments

x

a grid object.

asp

the aspect ratio of the plot.

min.val, max.val

The minimum and maximum values used for converting the values in the grid to the colors. Defaults to the minumum and maximum value in the grid. Only relevant when use.old is FALSE

add

If TRUE the image is overlayed on the current plot otherwise a new plot is generated.

na.col

The color to be used to plot NA values. By default they are left as NA which is plotted as transparent on most devices. This is only used when use.raster is TRUE.

use.raster

If TRUE rasterImage is used for plotting. If FALSE image is used. TRUE results in a faster and better plot but isn't supported on all machines, but Windows RDC users see note.

interpolate

This determines whether linear interpolation is used. The effect of changing this argument will be most evident when the number of cells plotted in the grid is much smaller than the pixel resolution of the graphics device; under those conditions turning interpolation on will tend to smooth the original cells in the grid. This is only used by the new version of the function.

col

A vector of colors to be used to plot values of the grid. If use.old is FALSE this is interpolated to create a color gradient with nramp values. If use.old is TRUE this is passed to link[graphics]{image}.

nramp

The number of distinct colors to be used when plotting. The default color palette or the palette specified by col is interpolated to create this many colors.

reverse.col

If TRUE the color ramp will be reversed.

restore.par

If TRUE (the default) graphics options (set by par) will be restored to their original settings. Use FALSE if you wish to plot additional information on top of the raster, however, this will leave the graphics device in a non-standard state - one way to return to normal is with dev.off which will close the device, allowing for a new device with default par settings.

...

Other arguments to image or rasterImage.

xlab, ylab

the label for the x and y axes. (Only used if use.old is TRUE.)

use.old

Depreciated. use.old = TRUE has the same effect as use.raster = FALSE.

Details

This is a convenience wrapper for either rasterImage or image. By default it causes the grid to be plotted with a 1:1 aspect ratio and a grayscale color ramp.

Value

Nothing is returned.

Note

When use.raster is TRUE this function uses rasterImage this is a much better way of plotting rasters than the older image function. However, it fails on remote desktop connections in Windows under the default configuration. To configure remote desktop so that this function will work follow directions here:

http://r.789695.n4.nabble.com/R-base-package-grid-does-not-output-raster-image-td4672188.html

Author(s)

Ethan Plunkett

See Also

grid

Examples


g <- dem

# Plot
plot(g)
plot(g, na.col="yellow")
plot(g, use.raster = FALSE) #  may work better on some devices


ethanplunkett/gridprocess documentation built on Feb. 1, 2024, 2:24 a.m.