tileplot {latticeExtra}R Documentation

Plot a spatial mosaic from irregular 2D points

Description

Represents an irregular set of (x, y) points with a color covariate. Polygons are drawn enclosing the area closest to each point. This is known variously as a Voronoi mosaic, a Dirichlet tesselation, or Thiessen polygons.

Usage

tileplot(x, data = NULL, aspect = "iso",
         prepanel = "prepanel.default.xyplot",
         panel = "panel.voronoi", ...)

Arguments

x, data formula and data as in levelplot, except that it expects irregularly spaced points rather than a regular grid.
aspect aspect ratio: "iso" is recommended as it reproduces the distances used in the triangulation calculations.
panel, prepanel see xyplot.
... further arguments to the panel function, which defaults to panel.voronoi.

Details

See panel.voronoi for further options and details.

Author(s)

Felix Andrews

See Also

panel.voronoi, levelplot

Alias

tileplot

Keyword

hplot

Examples

xyz <- data.frame(x = rnorm(100), y = rnorm(100), z = rnorm(100))
tileplot(z ~ x * y, xyz)

## tripack is faster but non-free
## Not run: 
tileplot(z ~ x * y, xyz, use.tripack = TRUE)
## End(Not run)

## showing rectangular window boundary
tileplot(z ~ x * y, xyz, xlim = c(-2, 4), ylim = c(-2, 4))

## insert some missing values
xyz$z[1:10] <- NA
## the default na.rm = FALSE shows missing polygons
tileplot(z ~ x * y, xyz, border = "black",
  col.regions = grey.colors(100),
  pch = ifelse(is.na(xyz$z), 4, 21),
  panel = function(...) {
    panel.fill("hotpink")
    panel.voronoi(...)
  })
## use na.rm = TRUE to ignore points with missing values
update(trellis.last.object(), na.rm = TRUE)

## a quick and dirty approximation to US state boundaries
tmp <- state.center
tmp$Income <- state.x77[,"Income"]
tileplot(Income ~ x * y, tmp, border = "black",
  panel = function(x, y, ...) {
    panel.voronoi(x, y, ..., points = FALSE)
    panel.text(x, y, state.abb, cex = 0.6)
  })

Results


R version 2.9.0 (2009-04-17)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(latticeExtra)
> png(filename="images/tileplot_%03d.png" ,width=480, height=480)
> ### Name: tileplot
> ### Title: Plot a spatial mosaic from irregular 2D points
> ### Aliases: tileplot
> ### Keywords: hplot
> 
> ### ** Examples
> 
> xyz <- data.frame(x = rnorm(100), y = rnorm(100), z = rnorm(100))
> tileplot(z ~ x * y, xyz)
deldir 0.0-8 
> 
> ## tripack is faster but non-free
> ## Not run: 
> ##D tileplot(z ~ x * y, xyz, use.tripack = TRUE)
> ## End(Not run)
> 
> ## showing rectangular window boundary
> tileplot(z ~ x * y, xyz, xlim = c(-2, 4), ylim = c(-2, 4))
> 
> ## insert some missing values
> xyz$z[1:10] <- NA
> ## the default na.rm = FALSE shows missing polygons
> tileplot(z ~ x * y, xyz, border = "black",
+   col.regions = grey.colors(100),
+   pch = ifelse(is.na(xyz$z), 4, 21),
+   panel = function(...) {
+     panel.fill("hotpink")
+     panel.voronoi(...)
+   })
> ## use na.rm = TRUE to ignore points with missing values
> update(trellis.last.object(), na.rm = TRUE)
> 
> ## a quick and dirty approximation to US state boundaries
> tmp <- state.center
> tmp$Income <- state.x77[,"Income"]
> tileplot(Income ~ x * y, tmp, border = "black",
+   panel = function(x, y, ...) {
+     panel.voronoi(x, y, ..., points = FALSE)
+     panel.text(x, y, state.abb, cex = 0.6)
+   })
> 
> 
> 
> dev.off()
null device 
          1 
> 






[Package latticeExtra Index]