#' Choose n colors using the golden ratio
#'
#' This choices n colors for you based on breaking up
#' the hues according to a sequence generated by the golden
#' ratio.
#'
#' @param n Integer. The number of colors you want
#' @param s Numeric. Saturation - input into hsv
#' @param v Numeric. Value - input into hsv
#' @param alpha Numeric. The alpha blending value that is input into hsv.
#' @export
#' @examples
#' cols <- goldenRatioColors(5)
#' plot(1:5, 1:5, col = cols)
#'
#' n <- 5
#' xs <- seq(1, n)
#' plot(c(1, n+1), c(0, 1), type = "n")
#' rect(xs, 0, xs + 1, 1, col = goldenRatioColors(n))
goldenRatioColors <- function(n, s = .5, v = 1, alpha = 1){
GR <- 2/(1 + sqrt(5))
hues <- (seq(0, n-1) * GR) %% 1
cols <- hsv(hues, s, v, alpha)
return(cols)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.