Description Usage Arguments Value Examples
View source: R/bivkey_percent_change.R
Plot change in bivariate space time data over time, built on keys from Vizumap::build_bkey
1 2 3 4 5 6 7 | bivkey_percent_change(
data.primary,
data.base,
key,
factor = bothVars,
labelSize = 5
)
|
data.primary |
the data for which change in bins (from data.base levels) should be calculated. Data built using st_assign_colors. |
data.base |
the data upon which the change in data.primary will be calculated. It is usually further in the past than data.primary. Build using st_assign_colors. |
key |
a key build using Vizumap::build_bkey. Ensure data has same bounds as key, either with st_change_key_bounds or building data in st_assign_colors with custom bounds |
factor |
the name of the factor variable in the data that contains the bins for bivariate data |
labelSize |
the size of the labels printed on the keys. See ggplot2::geom_label for more details. |
draws on the plot window
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | library(stars)
library(Vizumap)
library(gridExtra)
palette = build_palette(name = "BlueRed")
# 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)
# Find bounds on whole data set
out = st_assign_colors(tmax, 1, tmin, 1, FALSE, palette = palette)
bounds = out$bounds
# Preparing the data
out2 <- st_assign_colors(tmax[,,decades[[5]]], 1, tmin[,,decades[[5]]], 1, terciles = FALSE,
palette = palette, bounds = bounds)
data2 <- out2$data
out1 <- st_assign_colors(tmax[,,decades[[1]]], 1, tmin[,,decades[[1]]], 1, terciles = FALSE,
palette = palette, bounds = bounds)
data1 <- out1$data
# Build key
colnames(data1) = c("Tmax","Tmin","bothVars","hex_code")
colnames(data2) = c("Tmax","Tmin","bothVars","hex_code")
key <- build_bkey(data1, palette, terciles = FALSE)
key = st_change_key_bounds(key, bounds)
bivkey_percent_change(data.primary = data2, data.base = data1, key)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.