colormap: Maps Predicted Values and Clusters on a Two-Dimentional Map

View source: R/colormap.R

colormapR Documentation

Maps Predicted Values and Clusters on a Two-Dimentional Map

Description

Displays a color image map, including a legend, scale bar, and optional North arrow, showing values for a grid of points. Irregular grids are allowed. Also draws contour lines for regions of signficantly increased or decreased predicted values ("clusters").

Usage

colormap(obj, map=NULL, exp=FALSE, add=FALSE,  mapmin=NULL, mapmax=NULL, 
         col.seq=rev(rainbow(201,start=0,end=0.66)), anchor=FALSE,
         border.gray = 0.3, contours="none", 
         contours.drawlabels=FALSE, contours.lty=1,
         contours.lwd=1, contours.levels, contours.labcex=0.7, 
         interval.exclude=0, arrow=TRUE, axes=FALSE, ptsize=0.9, mai, 
         legend.name = "predicted values",legend.cex=1,
         legend.add.line,alpha,...)

Arguments

obj

(Required) A list containing at least these two elements: "grid" (a 2 column data frame with X and Y coordinates) and "fit" (the value to displayed on the map).

map

Can be used to map fit on a base map from the map function in the maps package, or on a base map produced by the readOGR function in the rgdal package. readOGR reads maps from external files in the ESRI shapefile format. map=NULL produces a color image without any base map.

exp

If exp=T, fit will be displayed in exponential scale.

add

Use add=T to add the color map to an existing plot. This will often result in loss of the legend and scale, which are added outside of the normal map boundaries. add is ignored when a map is provided using the map argument.

mapmin

The minimum value for the color scale legend. When not specified, it will be set to the minimum predicted value.

mapmax

The maximum value for the color scale legend. When not specified, it will be set to the maximum predicted value.

col.seq

The color sequence (palette) used to display the predicted values on the map. The default is a rainbow palette, but divergent or sequential palettes may be better for some applications. See the colorspace library and the example below for other options.

anchor

Use anchor=TRUE to center the color palette on legend.add.line. When anchor=FALSE (the default) or when legend.add.line is not specified, the color palette will be centered halfway between mapmin and mapmax. anchor=TRUE is recommended when using a divergent palette.

border.gray

Gray scale for the border of map, ranges from 0 to 1. It is white with border.gray=1, and black with border.gray=0. The defalt scale is 0.9.

contours

When contours="interval", two other elements conf.low and conf.high must be included in obj, and regions excluding a user-specified interval.exclude will be circled on the map. By specifying an element name in obj for contours, contour lines for the specified element will be added on the map, e.g. contours="fit" or contours="exp.fit" for a modgam object. The default is "none" which produces no contour lines.

contours.drawlabels

Use contours.drawlabels = TRUE add labels on contour lines.

contours.lty

The line type for contour lines

contours.lwd

The width for contour lines.

contours.levels

The levels for contour lines. When exp=T, the levels will also be used in an exponential scale.

contours.labcex

cex for contour labelling. This is an absolute size, not a multiple of par("cex")

interval.exclude

If contours="interval", regions with confidence intervals excluding interval.exclude will be circled

arrow

Use arrow=T to add a North arrow to the map.

axes

Use axes=T to add axes to the map (useful for chemical mixture isoboles).

ptsize

The size of the points used to fill in colors on the map. Increase to remove white space inside the map or decrease to remove color outside the map boundaries. NOTE: white space can also be eliminated by increasing the grid size in predgrid, which is often preferable as it results in a higher resolution map.

mai

The margins of the plot. Details see par,

legend.name

The name of displayed for the legend bar.

legend.cex

A numerical value giving the amount by which legend text should be magnified relative to the default.

legend.add.line

A numerical value at which a line will be added on the legend bar to indicate the color for the value.

alpha

Levels

...

Other auguments past to plot function

Value

Produces an image map. If the base map is in readOGR format a scale bar is included, showing whatever measurement units are recorded in the shapefile. If the units are missing from the shapefile conversion they are assumed to be meters.

Author(s)

Scott Bartell, Lu Bai, Robin Bliss, and Veronica Vieira

Send bug reports to sbartell@uci.edu.

See Also

trimdata, predgrid, plot.modgam.

Examples

data(MAdata)
data(MAmap)
obj <- list(grid=data.frame(MAdata$Xcoord,MAdata$Ycoord),fit=MAdata$Mercury)
colormap(obj, MAmap, legend.name = "mercury")

# map the same data using a divergent color palette anchored to the median
if (require(colorspace)) {
  newpal <- diverge_hsv(201)   # from the colorspace library
  colormap(obj, MAmap, legend.name = "mercury", col.seq = newpal, 
	legend.add.line=round(median(obj$fit),2), anchor = TRUE)
  }

MapGAM documentation built on July 26, 2023, 5:12 p.m.