Learn R Programming

fields (version 5.02)

quilt.plot: Image plot for irregular spatial data.

Description

Given a vector of z values associated with 2-d locations this function produces an image-like plot where the locations are discretized to a grid and the z values are coded as a color level from a color scale.

Usage

quilt.plot(x, y, z, nrow = 64, ncol = 64, grid = NULL, 
                     add.legend=TRUE,add=FALSE,col=tim.colors(256),...)

Arguments

Details

This function combines the discretization to an image by the function as.image and is then graphed by image.plot. Locations that fall into the same grid box will have their z values averaged.

A similar function exists in the lattice package and produces good looking plots. The advantage of this fields version is that it uses the standard R graphics functions and is written in R code. Also, the aggregation to average values for z values in the same grid box allows for different choices of grids. If two locations are very close, separating them could result in very small boxes.

As always, legend placement is never completely automatic. Place the legend independently for more control, perhaps using image.plot in tandem with split.screen or enlarging the plot margin See help(image.plot) for examples of this function and these strategies.

See Also

as.image, image.plot, lattice, persp, drape.plot

Examples

Run this code
data( ozone2)
# plot 16 day of ozone data set

quilt.plot( ozone2$lon.lat, ozone2$y[16,])
US( add=TRUE, col="grey", lwd=2)

#
# and ... if you are fussy 
# do it again 
# quilt.plot( ozone2$lon.lat, ozone2$y[16,],add=TRUE)
# to draw over the state boundaries. 
#

### adding a legend strip "by hand"
par( mar=c( 5,5,5,10)) # save some room for the legend
quilt.plot( ozone2$lon.lat, ozone2$y[16,], add.legend=FALSE)
image.plot(ozone2$lon.lat, ozone2$y[16,],legend.only=TRUE)

Run the code above in your browser using DataLab