Learn R Programming

lpjmlkit (version 1.0.11)

plot.LPJmLData: Plot an LPJmLData object

Description

Function to plot a time-series or raster map of an LPJmLData object.

Usage

# S3 method for LPJmLData
plot(x, subset = NULL, aggregate = NULL, raster_extent = NULL, ...)

Value

No return value; called for side effects.

Arguments

x

LPJmLData object

subset

List of array dimension(s) as name/key and corresponding subset vector as value, e.g. list(cell = c(27411:27416)). More information at subset.LPJmLData().

aggregate

List of array dimension(s) as name/key and corresponding aggregation function as value, e.g. list(band = sum).

raster_extent

Optional parameter to crop map display of spatial data. An extent or any object from which an Extent object can be extracted. Not relevant if aggregate includes spatial dimension.

...

Arguments passed to plot and plot

Details

Depending on the dimensions of the LPJmLData object's internal data array the plot will be a ...

  • single map plot: more than 8 "cell"s or "lat" & "lon" dimensions available)

  • multiple maps plot: length of one time (e.g."time", "year", "month") or "band" dimension > 1.

  • time series plot: less than 9 "cell"s

  • lat/lon plot: a subsetted/aggregated "lat" or "lon" dimension

The plot can only handle 2-3 dimensions. Use arguments subset and aggregate to modify x$data to the desired plot type. If more than three dimensions have length > 1,' plot will return an error and suggest to reduce the number of dimensions.

Note that the plot function aims to provide a quick overview of the data rather than create publication-ready graphs.

Examples

Run this code
if (FALSE) {

vegc <- read_io(filename = "./vegc.bin.json")

# Plot first 9 years starting from 1901 as a raster plot
plot(vegc)

# Plot raster with mean over the whole time series
plot(vegc,
     aggregate = list(time = mean))

# Plot only year 2010 as a raster
plot(vegc,
     subset = list(time = "2010"))

# Plot first 10 time steps as global mean time series. Note: Aggregation
# across cells is not area-weighted.
plot(vegc,
     subset = list(time = 1:10),
     aggregate = list(cell = mean))

# Plot time series for cells with LPJmL index 27410 - 27415 (C indices start
#    at 0 in contrast to R indices starting at 1).
plot(vegc,
     subset = list(cell = 27411:27416))

}

Run the code above in your browser using DataLab