Closed nutterb closed 7 years ago
I propose (to myself) two additional sprinkle systems.
discrete = c("bg", "font", "border")
discrete_colors = getOption("pixiedust_discrete_pal", NULL)
discrete_lighten_text = "white"
If no colors are given, the default colors from the scales
package will be used.
discrete_lighten_text
forces text to be white when the background is too dark. Only relevant for background colors. I need to talk to Joel about how he calculated this. Set to NULL to turn it off. May also be any other valid color.
gradient = c("bg", "font", "border")
gradient_n = 10
gradient_colors = getOption("pixied_gradient_color", c("#132B43", "#56B1F7"))
gradient_lighten_text = "white"
gradient_n
gives the number of shades to use between first and last colors
gradient_colors
gives the colors over which to shade. Must be at least two.
gradient_lighten_text
, same as discrete_lighten_text
For reference
library(scales)
library(pixiedust)
pal = gradient_n_pal(c("#132B43", "#56B1F7"))(seq(0, 1, length.out = 10))
pal_font = gradient_n_pal(c("#FFFFFF", "#000000"))(seq(0, 1, length.out = 10))
pal_discrete <- hue_pal()(2)
mpg_cut <- cut(mtcars$mpg,
breaks = quantile(mtcars$mpg, probs = seq(0, 1, length.out = 10)),
include.lowest = TRUE)
levels(mpg_cut)
dust(mtcars) %>%
sprinkle(col = "mpg",
bg = pal[as.numeric(mpg_cut)],
font_color = pal_font[as.numeric(mpg_cut)],
recycle = "rows") %>%
sprinkle(col = "am",
bg = pal_discrete[as.numeric(as.factor(mtcars$am))],
recycle = "rows") %>%
sprinkle_print_method("html")
check out this vignette in the
condformat
package, that does some cool work with automatically assigning colors, gradients, etc.https://cran.r-project.org/web/packages/condformat/vignettes/introduction.html
the
pixiedust
equivalent islibrary(pixiedust) library(RColorBrewer) data(iris)
output <- iris[c(1:5,70:75, 120:125),]
I think there's potential to do some cool sprinkles that automate some of that work.