violinPlot: Lattice plot methods for climatological series

View source: R/violinPlot.R

violinPlotR Documentation

Lattice plot methods for climatological series

Description

A wrapper for the lattice (trellis) plot methods for grid and station data.

Usage

violinPlot(
  ...,
  group.index = NULL,
  violin = TRUE,
  fill = TRUE,
  color.fun = list(FUN = mean, na.rm = TRUE),
  color.theme = "RdYlBu",
  color.cuts = NULL,
  rev.colors = FALSE,
  box.col = NULL,
  h.lines = NULL,
  v.lines = FALSE,
  lonLim = NULL,
  latLim = NULL,
  bwplot.custom = list()
)

Arguments

...

Input grids (or station data). It can be a list of grids too.

group.index

Character or numeric passed to argument group in bwplot.

violin

(default is TRUE). If FALSE, boxplots are returned.

fill

Logical indicating if the violins/boxes are filled with color. if TRUE, arguments color.fun, color.theme, color.cuts and rev.colors are used. Alternatively a vector with colors can be passed, in which case the mentioned arguments are ignored.

color.fun

list containing the function and the related arguments to perform spatial aggregation. The resulting values are used to fill with color the violins. Default is list(FUN = mean, na.rm = TRUE).

color.theme

A character string indicating the color theme to use in the map. Valid values are those available in the RColorBrewer themes. Additionally, the "jet.colors" palette can be used (the rainbow colors, in general not advised, though), for backwards compatibility. Default to the diverging, colorblind-friendly "RdYlBu" palette.

color.cuts

Numeric sequence indicating the color cuts.

rev.colors

Default to FALSE. If TRUE the reversed version of the color palette is used.

box.col

Character or numeric of the color to be given to the box borders.

h.lines

Numeric sequence indicating the position of dashed horizontal lines.

v.lines

Logical for drawing vertical lines (Default is FALSE).

lonLim

Vector of length = 2, with minimum and maximum longitude coordinates, in decimal degrees, of the bounding box selected. If NULL (default), the whole longitudinal range is selected

latLim

Same as lonLim, but for the selection of the latitudinal range.

bwplot.custom

List of arguments as passed to bwplot. Arguments panel cannot be modified, thus, if specified, it will be ignored.

Controlling graphical parameters

Many different aspects of the plot can be controlled passing the relevant arguments to bwplot. Fine control of graphical parameters for the trellis display can be also controlled using trellis.par.set.

Value

A lattice plot of class “trellis”.

Author(s)

M. Iturbide

Examples


require(climate4R.datasets)
data("EOBS_Iberia_tas")
data("EOBS_Iberia_pr")
data("CORDEX_Iberia_pr")
violinPlot("one" = climatology(EOBS_Iberia_pr),
           "two" = climatology(EOBS_Iberia_tas),
           "three" = climatology(CORDEX_Iberia_pr),
            h.lines = seq(0, 15, 5),
            color.cuts = seq(0, 3, 0.2),
            bwplot.custom = list(ylim = c(0, 20),
                                 ylab = "pr and tas"))

## With grouping:
data("EOBS_Iberia_tas")
data("EOBS_Iberia_pr")
data("CORDEX_Iberia_pr")
data("CORDEX_Iberia_tas")
violinPlot("pr" = climatology(EOBS_Iberia_pr),
           "tas" = climatology(EOBS_Iberia_tas),
           "pr" = climatology(CORDEX_Iberia_pr),
           "tas" = climatology(CORDEX_Iberia_tas),
            group.index = c("Measure1", "Measure1", "Measure2", "Measure2"),
            h.lines = seq(0, 15, 5),
            v.lines = TRUE,
            color.cuts = seq(0, 3, 0.2),
            bwplot.custom = list(ylim = c(0, 20),
                                 ylab = "pr and tas",
                                 as.table = TRUE))

## Boxplot:
data("EOBS_Iberia_tas")
data("EOBS_Iberia_pr")
data("CORDEX_Iberia_pr")
data("CORDEX_Iberia_tas")
a <- violinPlot("pr" = climatology(EOBS_Iberia_pr),
                "tas" = climatology(EOBS_Iberia_tas),
                violin = FALSE,
                fill = FALSE,
                h.lines = seq(0, 15, 5),
                v.lines = TRUE,
                box.col = "blue",
                bwplot.custom = list(ylim = c(0, 20),
                                     ylab = "pr and tas",
                                     as.table = TRUE,
                                     do.out = FALSE))
b <- violinPlot("pr" = climatology(CORDEX_Iberia_pr),
                "tas" = climatology(CORDEX_Iberia_tas),
                violin = FALSE,
                fill = FALSE,
                h.lines = seq(0, 15, 5),
                v.lines = TRUE,
                box.col = "green",
                bwplot.custom = list(ylim = c(0, 20),
                                     ylab = "pr and tas",
                                     as.table = TRUE,
                                     do.out = FALSE))
a + b


SantanderMetGroup/visualizeR documentation built on Oct. 28, 2023, 6:11 a.m.