Skip to content

Instantly share code, notes, and snippets.

View test.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View test2.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View bivariate.R
# from here:
# https://github.com/rstudio/gt/blob/ff878e10d21a3ba897c5f99801b796da8fb637fa/R/helpers.R#L2496-L2536
adjust_luminance <- function(colors, steps) {
stopifnot(steps < 2, steps > -2)
rgb_matrix <- t(grDevices::col2rgb(colors, alpha = TRUE)) / 255
alpha <- rgb_matrix[, "alpha"]
luv_matrix <-
grDevices::convertColor(rgb_matrix[, 1:3], "sRGB", "Luv")
h <- atan2(luv_matrix[, "v"], luv_matrix[, "u"]) * 180 / pi
c <- sqrt(luv_matrix[, "u"]^2 + luv_matrix[, "v"]^2)