st_multiple_histograms: st_multiple_histograms

Description Usage Arguments Examples

View source: R/st_multiple_histograms.r

Description

Create multiple plots of bivariate spatio-temporal data along chosen dimension values

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
st_multiple_histograms(
  starsObj1,
  attr1,
  starsObj2,
  attr2,
  dim_values,
  terciles,
  which = 1,
  titles,
  bounds = NULL,
  palette = NULL
)

Arguments

starsObj1

a stars object

attr1

which attribute of starsObj1 should be plotted?

starsObj2

a stars object

attr2

which attribute of starsObj2 should be plotted?

dim_values

the dimension values along which to create plots. Should be a list. Note that the actual indices of the dimension values are needed, see examples

terciles

should terciles be calculated?

which

which dimension is the one of interest? Should take a value between 1 and 3 (inclusive), use aperm() if need be

titles

titles of the plots, should be of the same length as dim_values

bounds

if custom bounds should be plotted, default NULL

palette

palette

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# matched time to decadal time periods and produce histograms
time <- as.numeric(st_get_dimension_values(tmax, 2))
periods <- list(c(1950:1959), c(1960:1969), c(1970:1979), c(1980:1989),c(1990:1999))
decades <- lapply(periods, function(x, time) which(time %in% x), time)

histograms <- st_multiple_histograms(tmax, 1, tmin, 1, dim_values = decades,
                 terciles = TRUE, which = 2, titles = c(1:5))
colnames(data) = c("Tmax","Tmin","bothVars","hex_code")
key <- build_bkey(data, palette, terciles = TRUE)

attach_key(arrangeGrob(histograms[[1]], histograms[[5]], ncol = 1), key)

JamesMCollier/densityviz documentation built on Dec. 18, 2021, 12:31 a.m.