SymbolixAU / colourvalues

R library for assigning colours to values
https://symbolixau.github.io/colourvalues/
46 stars 6 forks source link

print coloured values #55

Closed SymbolixAU closed 4 years ago

SymbolixAU commented 5 years ago

something like this / is it worth it?

print_values <- function(x, ... ) {
  m <- colourvalues::colour_values_rgb(x, ...)
  ## copied from crayon:::ansi256_rgb_index
  v <- 16 + rowSums(floor(6 * m[,1:3] / 256 ) * matrix(c(36,6,1), ncol = 3, nrow = nrow(m), byrow = T)) + 1
  cat(paste0("\033[48;5;",v, 'm',x,"\033[39m"))
}

df <- data.frame(
  x = round( rnorm(500), 2 )
)

print_values( df$x, palette = "inferno" )

maybe call it colourvalues::show_coloured_values ?, or preview_colours()

Screen Shot 2019-09-24 at 3 25 36 pm

and why is this wrong?

print_values( sort( df$x ), palette = "sequential_hcl" )
SymbolixAU commented 4 years ago

I don't think this adds anything, other than bloat.