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").
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,...)
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.
(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).
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.
If exp=T
, fit
will be displayed in exponential scale.
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.
The minimum value for the color scale legend. When not specified, it will be set to the minimum predicted value.
The maximum value for the color scale legend. When not specified, it will be set to the maximum predicted value.
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.
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.
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.
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.
Use contours.drawlabels = TRUE
add labels on contour lines.
The line type for contour lines
The width for contour lines.
The levels for contour lines. When exp=T
, the levels will also be used in an exponential scale.
cex for contour labelling. This is an absolute size, not a multiple of par("cex")
If contours="interval"
, regions with confidence intervals excluding interval.exclude
will be circled
Use arrow=T to add a North arrow to the map.
Use axes=T to add axes to the map (useful for chemical mixture isoboles).
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.
The margins of the plot. Details see par,
The name of displayed for the legend bar.
A numerical value giving the amount by which legend text should be magnified relative to the default.
A numerical value at which a line will be added on the legend bar to indicate the color for the value.
Levels
Other auguments past to plot function
Scott Bartell, Lu Bai, Robin Bliss, and Veronica Vieira
Send bug reports to sbartell@uci.edu.
trimdata
,
predgrid
,
plot.modgam
.
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)
}
Run the code above in your browser using DataLab