Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

bwplot-methods

Box and whisker plots of Raster objects.


Description

Methods for bwplot and RasterStackBrick objects using a combination of panel.violin and panel.bwplot to compose the graphic.

Usage

## S4 method for signature 'RasterStackBrick,missing'
bwplot(x, data=NULL, layers, FUN,
            maxpixels = 1e+05,
            xlab='', ylab='', main='',
            violin = TRUE, draw.points = FALSE, do.out = FALSE,
            par.settings = bwTheme(),
            violin.ratio = 1, box.ratio = 0.5,
            scales=list(x=list(rot=45, cex=0.8)),
            ...)
## S4 method for signature 'formula,Raster'
bwplot(x, data, dirXY, 
            maxpixels = 1e+05,
            xscale.components=xscale.raster,
            yscale.components=yscale.raster,
            horizontal=FALSE,
            violin = TRUE, draw.points = FALSE, do.out = FALSE,
            violin.ratio = 1, box.ratio = 0.5,
            par.settings = bwTheme(),
            ...)
## S4 method for signature 'SpatRaster,missing'
bwplot(x, data=NULL, layers, FUN,
            maxpixels = 1e+05,
            xlab='', ylab='', main='',
            violin = TRUE, draw.points = FALSE, do.out = FALSE,
            par.settings = bwTheme(),
            violin.ratio = 1, box.ratio = 0.5,
            scales=list(x=list(rot=45, cex=0.8)),
            ...)
## S4 method for signature 'formula,SpatRaster'
bwplot(x, data, dirXY, 
            maxpixels = 1e+05,
            xscale.components=xscale.raster,
            yscale.components=yscale.raster,
            horizontal=FALSE,
            violin = TRUE, draw.points = FALSE, do.out = FALSE,
            violin.ratio = 1, box.ratio = 0.5,
            par.settings = bwTheme(),
            ...)

Arguments

x

A RasterStackBrick object, a SpatRaster object, or a formula.

data

NULL, a Raster object, or a SpatRaster object.

layers

A numeric or character which should indicate the layers to be displayed.

dirXY

A direction as a function of the coordinates (see xyLayer).

FUN

A function to applied to the z slot of a RasterStackBrick object, or the time index of a SpatRaster object. The result of this function is used as the grouping variable of the plot.

maxpixels

A numeric, for sampleRandom or spatSample.

xscale.components, yscale.components

Graphical parameters of lattice. See xyplot for details.

horizontal

Defaults to FALSE, meaning that the right hand of the formula is a factor or shingle.

xlab, ylab, main

Labels for axis and title

.

violin

Logical, if TRUE the panel is built with panel.violin and panel.bwplot.

draw.points

Logical, if TRUE raw points are displayed in the background with panel.stripplot

do.out

Logical, if TRUE outliers are drawn.

box.ratio

ratio of box thickness to inter box space

violin.ratio

ratio of the thickness of each violin and inter violin space

par.settings, scales

See xyplot for details.

...

Additional arguments for bwplot

Author(s)

Oscar Perpiñán Lamigueiro

See Also

Examples

f <- system.file("external/test.grd", package="raster")
r <- raster(f)
s <- stack(r, r-500, r+500)
bwplot(s)

bwplot(s, violin = FALSE, box.ratio = 1)

## Modify colours
myTheme <- bwTheme(
    box.rectangle = list(col = 'green', fill = 'lightgreen'),
    plot.polygon = list(col = 'blue'),
    plot.symbol = list(col = 'gray', cex = 0.8, alpha = 0.1)
)
## Display raw points
bwplot(s, draw.points = TRUE,
       par.settings = myTheme)

## Not run: 

dataURL <- "https://raw.github.com/oscarperpinan/bookvis/master/data/"

##Solar irradiation data from CMSAF http://dx.doi.org/10.5676/EUM_SAF_CM/RAD_MVIRI/V001
old <- setwd(tempdir())
download.file(paste0(dataURL, "SISmm2008_CMSAF.zip"),
   "SISmm2008_CMSAF.zip", method='wget')
unzip("SISmm2008_CMSAF.zip")

listFich <- dir(pattern='\\.nc')
stackSIS <- stack(listFich)
stackSIS <- stackSIS*24 ##from irradiance (W/m2) to irradiation Wh/m2
setwd(old)

idx <- seq(as.Date('2008-01-15'), as.Date('2008-12-15'), 'month')

SISmm <- setZ(stackSIS, idx)
names(SISmm) <- month.abb

bwplot(SISmm)

##FUN applies to z if not NULL
library(zoo)

bwplot(SISmm, FUN=as.yearqtr)

## End(Not run)
## Not run: 
##http://neo.sci.gsfc.nasa.gov/Search.html?group=64
old <- setwd(tempdir())
download.file(paste0(dataURL, "875430rgb-167772161.0.FLOAT.TIFF"),
   "875430rgb-167772161.0.FLOAT.TIFF", method='wget')

pop <- raster("875430rgb-167772161.0.FLOAT.TIFF")
pop[pop==99999] <- NA
levelplot(pop, zscaleLog=10, par.settings=BTCTheme,
          panel=panel.levelplot.raster, interpolate=TRUE)

##http://neo.sci.gsfc.nasa.gov/Search.html?group=20
download.file(paste0(dataURL, "241243rgb-167772161.0.TIFF"),
   "241243rgb-167772161.0.TIFF", method='wget')
landClass <- raster("241243rgb-167772161.0.TIFF")
landClass[landClass==254] <- NA


s <- stack(pop, landClass)
names(s) <- c('pop', 'landClass')

bwplot(asinh(pop) ~ landClass|cut(y, 3), data = s,
       layout = c(3, 1))

bwplot(asinh(pop) ~ cut(y, 5)|landClass, data = s,
       scales = list(x=list(rot=45)), layout = c(4, 5),
       strip = strip.custom(strip.levels = TRUE))

## Modify colours
bwplot(asinh(pop) ~ cut(y, 5)|landClass, data = s,
       scales = list(x=list(rot=45)), layout = c(4, 5),
       strip = strip.custom(strip.levels = TRUE),
       par.settings = bwTheme(plot.polygon = list(col = 'lightgray'),
                              box.rectangle = list(fill = 'lightgreen')))

## End(Not run)

rasterVis

Visualization Methods for Raster Data

v0.50.2
GPL-3
Authors
Oscar Perpinan Lamigueiro [cre, aut] (<https://orcid.org/0000-0002-4134-7196>), Robert Hijmans [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.