ggautoimage {autoimage}R Documentation

Display images using ggplot2

Description

ggautoimage produces a sequence of images in a manner similar to autoimage using the ggplot2 package.

Usage

ggautoimage(
  x,
  y,
  z,
  f,
  proj = "none",
  parameters,
  orientation,
  lines,
  points,
  interp.args
)

Arguments

x

A numeric vector specifying the x coordinate locations.

y

A numeric vector specifying the y coordinate locations.

z

A numeric vector specifying the response for each (x,y) location.

f

A factor variable distinguishing between different facets, i.e., the different images to be constructed.

proj

A character string indicating what projection should be used for the included x and y coordinates. The default is "none". The other valid choices correspond to the "projection" argument in the mapproject function, which is used for the projection.

parameters

A numeric vector specifying the values of the parameters argument in the mapproject. This may be necessary when proj != "none".

orientation

A vector c(latitude,longitude,rotation) which describes where the "North Pole" should be when computing the projection. See mapproject for more details.

lines

A named list with components x and y specifiying the locations to be connected by lines. Distinct lines should be separated by NA values. See Details.

points

A named list with components x and y specifiying the locations to be plot points.

interp.args

A named list with component matching the non xyz arguments of the mba.surf function. Used to customize interpolation, when required.

Details

If x and y do not form a regular grid, then the mba.surf function is used to interpolate the locations onto a regular grid before constructing the image. This interpolation can be customized by passing interp.args through .... interp.args should be a named list with components matching the non xyz arguments of the mba.surf function.

When proj != "none", the mapproject function is used to project the x and y coordinates. In that case, proj must correspond to one of the choices for the projection argument in the mapproject function. Necessary arguments for mapproject should be provided through the parameters and orientation arguments. See Examples or mapproject for more details.

Lines can be added to each image by providing the lines argument. In that case, lines should be a list with components x and y specifying the locations to draw the lines. If more than one unconnected line should be drawn, then the coordinates should be separated by NA. e.g., to draw a line from (1, 1) to (2, 2) and (3, 3) to (4, 4) (with a gap between the two lines), you would specify lines as lines(x = c(1:2, NA, 3:4), y =c(1:2, NA, 3:4)). Also, see Examples.

Points can be added to each image by providing the points argument. In that case, points should be a list with components x and y specifying the locations to draw the points.

See Also

autoimage, image.plot, axis

Examples

data(narccap)
# setup image for two days of narccap data
x <- rep(c(lon), 2)
y <- rep(c(lat), 2)
z <- c(tasmax[, , 1:2])
f <- factor(rep(c("day 1", "day 2"), each = length(lon)))
# load national borders
data("worldMapEnv", package = "maps")
lines <- maps::map("world", plot = FALSE)
# obtain us captial cities
data(us.cities, package = "maps")
cap <- us.cities[us.cities$capital == 2, ]
# convert to list format
points <- list(x = cap$lon, y = cap$lat)

## Not run: 
# basic images
ggautoimage(x, y, z, f)
# basic images with national borders and U.S. captials
ggautoimage(x, y, z, f, lines = lines, points = points)
# project coordinates with national borders and U.S. capitals
ggautoimage(x, y, z, f, lines = lines, points = points,
            proj = "bonne", parameters = 40)
# finer interpolation grid
ggautoimage(x, y, z, f, lines = lines, points = points,
            interp.args = list(no.X = 100, no.Y = 100))

## End(Not run)

[Package autoimage version 2.2.3 Index]