# NOT RUN {
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 = brewer.pal(9, "Purples"),
alpha.line = 0.5))
suppressWarnings(print(
mapplot(county ~ log10(population), ancestry, map = county.map,
colramp = NULL)
))
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")))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab