Description Usage Arguments Value Note Author(s) References See Also Examples
Produces Trellis displays of numeric (and eventually categorical) data on a map. This is largely meant as a demonstration, and users looking for serious map drawing capabilities should look elsewhere (see below).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | mapplot(x, data, ...)
## S3 method for class 'formula'
mapplot(x, data, map, outer = TRUE,
prepanel = prepanel.mapplot,
panel = panel.mapplot,
aspect = "iso",
legend = NULL,
breaks, cuts = 30,
colramp = colorRampPalette(hcl.colors(n = 11, palette = "Spectral")),
colorkey = TRUE,
...)
prepanel.mapplot(x, y, map, ...)
panel.mapplot(x, y, map, breaks, colramp, exact = FALSE, lwd = 0.5, ...)
|
x, y |
For Suitable subsets (packets) of |
data |
A data source where names in the formula are evaluated |
map |
An object of class |
The remaining arguments are standard lattice arguments, relvant here mostly because they have different defaults than usual:
outer |
logical; how variables separated by |
prepanel, panel |
the prepanel and panel functions |
aspect |
aspect ratio |
breaks, cuts, colramp |
controls conversion of numeric |
exact |
the default |
legend, colorkey |
controls legends; usually just a color key
giving the association between numeric values of |
lwd |
line width |
... |
Further arguments passed on to the underlying engine.
See |
An object of class "trellis"
.
This function is meant to demonstrate how maps can be incorporated in a Trellis display. Users seriously interested in geographical data should consider using software written by people who know what they are doing.
Deepayan Sarkar
http://en.wikipedia.org/wiki/Choropleth_map
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | library(maps)
library(mapproj)
## Note: Alaska, Hawaii and others are not included in county map;
## this generates warnings with both USCancerRates and ancestry.
data(USCancerRates)
suppressWarnings(print(
mapplot(rownames(USCancerRates) ~ log(rate.male) + log(rate.female),
data = USCancerRates,
map = map("county", plot = FALSE, fill = TRUE,
projection = "mercator"))
))
suppressWarnings(print(
mapplot(rownames(USCancerRates) ~ log(rate.male) + log(rate.female),
data = USCancerRates,
map = map("county", plot = FALSE, fill = TRUE,
projection = "tetra"),
scales = list(draw = FALSE))
))
data(ancestry)
county.map <-
map('county', plot = FALSE, fill = TRUE,
projection = "azequalarea")
## set a sequential color palette as current theme, and use it
opar <- trellis.par.get()
trellis.par.set(custom.theme(region = rev(hcl.colors(9, "Purp")),
alpha.line = 0.5))
suppressWarnings(print(
mapplot(county ~ log10(population), ancestry, map = county.map,
colramp = NULL, border = "transparent")
))
trellis.par.set(opar)
## Not run:
## this may take a while (should get better area records)
county.areas <-
area.map(county.map, regions = county.map$names, sqmi = FALSE)
ancestry$density <-
with(ancestry, population / county.areas[as.character(county)])
mapplot(county ~ log(density), ancestry,
map = county.map, border = NA,
colramp = colorRampPalette(c("white", "black")))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.