SCM Repository

[latticeextra] View of /www/man/mapplot.html
ViewVC logotype

View of /www/man/mapplot.html

Parent Directory Parent Directory | Revision Log Revision Log

Revision 143 - (download) (as text) (annotate)
Tue May 25 06:54:57 2010 UTC (9 years ago) by felix
File size: 5983 byte(s)
get rid of ".featured_example", just use example number
<html><head><title>R: Trellis displays on Maps a.k.a. Choropleth maps</title>


<table width="100%" summary="page for mapplot {latticeExtra}"><tr><td>mapplot {latticeExtra}</td><td align="right">R Documentation</td></tr></table>

<h2>Trellis displays on Maps a.k.a. Choropleth maps</h2>


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).



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(brewer.pal(n = 11, name = "Spectral")),
        colorkey = TRUE,

prepanel.mapplot(x, y, map, ...)
panel.mapplot(x, y, map, breaks, colramp, exact = FALSE, lwd = 0.5, ...)



<table summary="R argblock">
<tr valign="top"><td><code>x, y</code></td>
 For <code>mapplot</code>, an object on which method dispatch is
carried out.  For the formula method, a formula of the form <code>y
      ~ x</code>, with additional conditioning variables as desired.  The
extended form of conditioning using <code>y ~ x1 + x2</code> etc. is also
allowed.  The formula might be interpreted as in a dot plot, except
that <code>y</code> is taken to be the names of geographical units in
Suitable subsets (packets) of <code>x</code> and <code>y</code> are passed to
the prepanel and panel functions.
<tr valign="top"><td><code>data</code></td>
 A data source where names in the formula are evaluated </td></tr>
<tr valign="top"><td><code>map</code></td>
 An object of class <code>"map"</code> (package <code>maps</code>),
containing boundary information.  The names of the geographical
units must match the <code>y</code> variable in the formula.  </td></tr>
The remaining arguments are standard lattice arguments, relvant here
mostly because they have different defaults than usual:
<tr valign="top"><td><code>outer</code></td>
 logical; how variables separated by <code>+</code> in the
formula are interpreted.  It is not advisable to change the
default.  </td></tr>
<tr valign="top"><td><code>prepanel, panel</code></td>
 the prepanel and panel functions </td></tr>
<tr valign="top"><td><code>aspect</code></td>
 aspect ratio</td></tr>
<tr valign="top"><td><code>breaks, cuts, colramp</code></td>
 controls conversion of numeric <code>x</code>
values to a false color.  <code>colramp</code> should be
a function that produces colors (such as <code>cm.colors</code>).
If it is <code>NULL</code>, colors are taken from
<code>trellis.par.get("regions")</code>. </td></tr>
<tr valign="top"><td><code>exact</code></td>
 the default <code>exact = FALSE</code> allows the given
<code>y</code> values to match sub-regions of <code>map</code>,
i.e. region names with a qualifier following <code>":"</code>, like
<code>"michigan:north", "michigan:south"</code>. These will both match a
<code>y</code> value of <code>"Michigan"</code>. </td></tr>
<tr valign="top"><td><code>legend, colorkey</code></td>
 controls legends; usually just a color key
giving the association between numeric values of <code>x</code> and
color.  </td></tr>
<tr valign="top"><td><code>lwd</code></td>
line width</td></tr> 
<tr valign="top"><td><code>...</code></td>
 Further arguments passed on to the underlying engine.
See <code>xyplot</code> for details.  </td></tr>


An object of class <code>"trellis"</code>.


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.


<p> Deepayan Sarkar </p>


<p> <a href=""></a> </p>

<h3>See Also</h3>

<p> <code>Lattice</code>  </p>





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) &lt;- 
    map('county', plot = FALSE, fill = TRUE, 
        projection = "azequalarea")

## set a sequential color palette as current theme, and use it
opar &lt;- trellis.par.get()
trellis.par.set(custom.theme(region = brewer.pal(9, "Purples"),
                             alpha.line = 0.5))
mapplot(county ~ log10(population), ancestry, map =,
    colramp = NULL)

## Not run: 

## this may take a while (should get better area records)

county.areas &lt;-, regions =$names, sqmi = FALSE)
ancestry$density &lt;- 
    with(ancestry, population / county.areas[as.character(county)])

mapplot(county ~ log(density), ancestry,
        map =, border = NA,
        colramp = colorRampPalette(c("white", "black")))

## End(Not run)


<div align="center">[Package <em>latticeExtra</em> version 0.6-12 <a href="00Index.html">Index</a>]</div>
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge