library(maps)
library(mapproj)
data(USCancerRates)
.featured_example <- "USCancerRates"
mapplot(rownames(USCancerRates) ~ log(rate.male) + log(rate.female),
data = USCancerRates,
map = map("county", plot = FALSE, fill = TRUE,
projection = "mercator"))
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")
.featured_example <- "mapplot"
## 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))
mapplot(county ~ log10(population), ancestry, map = county.map,
colramp = NULL)
trellis.par.set(opar)
## 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")))
Run the code above in your browser using DataLab