Learn R Programming

spdep (version 0.1-13)

plotpolys: Plot polygons

Description

A helper function for plotting polygons in a global bounding box. findInterval2 is a modified version of findInterval2 that permits the vector of break points to start at -Inf and/or finish at Inf. leglabs makes character strings from the same break points.

Usage

plotpolys(pl, bb, col = NA, border = par("fg"), add = FALSE, xlim, ylim, ...)
leglabs(vec, under="under", over="over", between="-")
findInterval2(x, vec, rightmost.closed = FALSE, all.inside = TRUE)

Arguments

pl
list of polygons of class polylist
bb
matrix of polygon bounding boxes - columns are LL(x), LL(y), UR(x), UR(y)
col
colurs to use for filling the polygons
border
the color to draw the border
add
add to existing plot
xlim, ylim
numeric of length 2, giving the x and y coordinates ranges
...
other arguments passed to polygon
vec
vector of break values
under
character value for under
over
character value for over
between
character value for between
x
numeric vector to be broken into class intervals
rightmost.closed
as in findInterval()
all.inside
as in findInterval()

See Also

Map2poly, findInterval

Examples

Run this code
data(columbus)
brks <- round(quantile(columbus$CRIME, probs=seq(0,1,0.2)), digits=2)
colours <- c("salmon1", "salmon2", "red3", "brown", "black")
plotpolys(polys, bbs, col=colours[findInterval2(columbus$CRIME, brks)])
legend(x=c(5.8, 7.1), y=c(13, 14.5), legend=leglabs(brks),
  fill=colours, bty="n")
title(main=paste("Columbus OH: residential burglaries and vehicle
thefts",
  "per thousand households, 1980"))

Run the code above in your browser using DataLab