Learn R Programming

rasterVis (version 0.10-2)

gplot-methods: Use ggplot to plot a Raster* object

Description

A wrapper function around ggplot (ggplot2 package). Note that the function in the raster package is called gplot with a single 'g'.

Usage

## S3 method for class 'Raster':
gplot(x, maxpixels=50000,...)

Arguments

docType

methods

See Also

plot, spplot

Examples

Run this code
r <- raster(system.file("external/test.grd", package="raster"))
s <- stack(r, r*2)
layerNames(s) <- c('meuse', 'meuse x 2')

if (require(ggplot2)) {
  theme_set(theme_bw())
  gplot(s) + geom_tile(aes(fill = value)) + facet_wrap(~ variable) +
            scale_fill_gradient(low = 'white', high = 'blue') + coord_equal()
}

Run the code above in your browser using DataLab