map(database, regions) # simple form
map(database = "world", regions = ".", exact = FALSE, boundary = TRUE,
interior = TRUE, projection = "", parameters = NULL, orientation = NULL,
fill = FALSE, col = 1, plot = TRUE, add = FALSE, namesonly = FALSE,
xlim = NULL, ylim = NULL, wrap = FALSE, resolution = if(plot) 1 else 0,
type = "l", bg = par("bg"), mar = c(4.1, 4.1, par("mar")[3], 0.1),
border = 0.01, ...)
x
, y
, and names
obtained from a previous call to
map
.
The string choices include a world<
TRUE
, only exact matches with regions
are
selected for drawing.
If FALSE
, each element of regions
is matched
as a regular expression
against the polygon names in the database and all mFALSE
, boundary segments are not drawn.
A boundary segment is a line segment of the map that bounds only
one of the polygons to be drawn.
This argument is ignored if fill
is TRUE
.FALSE
, interior segments are not drawn.
An interior segment is a line segment of the map that bounds two
of the polygons to be drawn.
This argument is ignored if fill
is TRUE
.mapproject
(in the mapproj
library).
The default is to use a rectangular projection with the aspect ratio
chosen sprojection
argument.
This argument is optional only in the sense that certain
projections do not require additional parameters.
If a projection does require additional parameters, c(latitude, longitude, rotation)
describing where
the map should be centered and a clockwise rotation (in degrees)
about this center.FALSE
, the lines bounding each region will be drawn (but
only once, for interior lines).
If TRUE
, each region will be filled using colors from the
fill
is FALSE
, the first color is used for plotting
all lines, and any other colors are ignored.
Otherwise, the colors are matched one-one with the polygons
that get selected by the regi
plot
is TRUE
the return value of map
will
not be printed automatically .FALSE
, a new plot is begun, and a new coordinate
system is set up.TRUE
, the return value will be a character vector of
the names of the selected polygons. See the Value section below.type = "l"
, the value type = "n"
can be used
to set up the coordinate system and projection for a map that will
be added to in later calls.par
. Defaults allow for map.axes().polygon
or lines
.plot = TRUE
, a plot is made where
the polygons selected from database
, through the
regions
, xlim
, and ylim
arguments, are outlined
(fill
is FALSE
) or filled (fill
is TRUE
)
with the colors in col
. The return value is a list with
x
, y
, range
, and names
components.
This object can be used as a database
for successive calls
to map
and functions.
If fill
is FALSE
, the x
and y
vectors are
the coordinates of successive polylines, separated by NA
s. If
fill
is TRUE
, the x
and y
vectors have
coordinates of successive polygons, again separated by NA
s.
Thus the return value can be handed directly to lines
or
polygon
, as appropriate.
When namesonly
is TRUE
, only the names component is returned.
After a call to map
for which the projection
argument was
specified there will be a global variable .Last.projection
containing information about the projection used.
This will be consulted in subsequent calls to map
which use
projection = ''
.
Richard A. Becker, and Allan R. Wilks,
"Constructing a Geographical Database",
AT&T Bell Laboratories Statistics Research Report [95.2], 1995.
map.text
, map.axes
,
map.scale
, map.grid
(in the mapproj
library)map() # low resolution map of the world
map('usa') # national boundaries
map('county', 'new jersey') # county map of New Jersey
map('state', region = c('new york', 'new jersey', 'penn')) # map of three states
map("state", ".*dakota", border = 0) # map of the dakotas
map.axes() # show the effect of border = 0
if(require(mapproj))
map('state', proj = 'bonne', param = 45) # Bonne equal-area projection of states
# names of the San Juan islands in Washington state
map('county', 'washington,san', names = TRUE, plot = FALSE)
# national boundaries in one linetype, states in another
# (figure 5 in the reference)
map("state", interior = FALSE)
map("state", boundary = FALSE, lty = 2, add = TRUE)
# plot the ozone data on a base map
# (figure 4 in the reference)
data(ozone)
map("state", xlim = range(ozone$x), ylim = range(ozone$y))
text(ozone$x, ozone$y, ozone$median)
box()
Run the code above in your browser using DataLab