raster (version 2.1-41)

text: Add labels to a map

Description

Plots labels, that is a textual (rather than color) representation of values, on top an existing plot (map).

Usage

## S3 method for class 'RasterLayer':
text(x, labels, digits=0, fun=NULL, ...)

## S3 method for class 'RasterStackBrick':
text(x, labels, digits=0, fun=NULL, ...)

## S3 method for class 'SpatialPolygons':
text(x, labels, ...)

## S3 method for class 'SpatialPoints':
text(x, labels, ...)

Arguments

x
Raster*, SpatialPoints* or SpatialPolygons* object
labels
Character. Optional. Vector of labels with length(x) or a variable name from names(x)
digits
Integer. how many digits should be used?
fun
Function to subset the values plotted (as in rasterToPoints)
...
Additional arguments to pass to graphics function text

See Also

text, plot

Examples

Run this code
r <- raster(nrows=4, ncols=4)
r <- setValues(r, 1:ncell(r))
plot(r)
text(r)

plot(r, col=bpy.colors(5))
text(r, fun=function(x){x<5 | x>12}, col=c('red', 'white'), vfont=c("sans serif", "bold"), cex=2)

Run the code above in your browser using DataLab