R/list_plotter.R

Defines functions list_plotter

Documented in list_plotter

#' Function to plot palette within a list
#'
#' @param color_list
#' @param names
#' @param package_name
#'
#' @return
list_plotter <- function(color_list, names, package_name) {
  par(mar = c(0, 0, 0, 0) + 0.1)

  plot(0, 0, type = "n", axes = FALSE, bty = "n", xlab = "", ylab = "",
       xlim = c(0, 1), ylim = c(-length(color_list)-1, 0))

  title(package_name, line = -3)
  for (i in seq_len(length(color_list))) {

    colors_len <- length(color_list[[i]])
    breaks <- seq(from = 0, to = 1, length = colors_len + 1)


    text(0, -i, names[i], pos = 4)
    rect(xleft = breaks[1:colors_len], xright = breaks[1:colors_len + 1],
         ytop = - 0.15-i, ybottom = -0.8-i,
         col = color_list[[i]], border = NA)
  }
}
JBLecomte/JBUtilities documentation built on March 31, 2021, 7:25 p.m.