knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
# library(customColors) # library(devtools) if (require("paletter")) {devtools::install_github("andreacirilloac/paletter")} if (require("shades")) {install.packages("shades")}
Source : \http://www.milanor.net/blog/build-color-palette-from-image-with-paletter/
library(paletter) colours_vector <- paletter::create_palette("elecSJ_1024px.jpg", number_of_colors = 12, type_of_variable = "categorical")
# Vector after reordering and naming colours shades::swatch(colorVector) reorder <- c(1, 10, 4, 6, 2, 5, 3, 12, 7, 9, 8 , 11) shades::swatch(colorVector[reorder]) colorVector2 <- colorVector[reorder] names(colorVector2) <- c("brown", "brownRed", "greyDark", "greyBlue", "red", "greyMedium", "beige", "pinkDark", "greyLight", "greyRed", "purpleLight", "pinkLight" ) names(colorVector2) shades::swatch(colorVector2) dput(colorVector2)
colorVectorTrimet <- paletter::create_palette("trimetLogo.jpg", number_of_colors = 2, type_of_variable = "categorical", optimize_palette = F ) names(colorVectorTrimet) <- c("white", "blue") dput(colorVectorTrimet)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.