Skip to content

Instantly share code, notes, and snippets.

@padpadpadpad
Created March 14, 2024 16:45
Show Gist options
  • Save padpadpadpad/d27d437103e8063b8209cf4f3fb9e944 to your computer and use it in GitHub Desktop.
Save padpadpadpad/d27d437103e8063b8209cf4f3fb9e944 to your computer and use it in GitHub Desktop.
# set colours for plot
colours <- RColorBrewer::brewer.pal(10, 'Spectral')
# function to make points lighter but not transparent
alpha_hex <- function(hex_code, alpha = 1){
# split by ',' and extract number
temp <- monochromeR::hex_to_rgb(hex_code) %>%
str_split(., ',') %>%
.[[1]] %>%
parse_number()
return(rgba_to_hex(c(temp, alpha)))
}
alpha_hex('purple', 0.8)
scales::alpha('purple', 0.8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment