class: center, middle, title-slide # palette2vec ## A new way to explore color palettes ### Emil Hvitfeldt --- # My history with color palettes -- ![](images/colorpalette-repo.png) --- # My history with color palettes ![](images/paletteer-repo.png) --- # My history with color palettes ![](images/bot-paletteer.png) --- .pull-left[ ![:scale 200%](images/bot-paletteer-post1.png) ] .pull-right[ ![:scale 200%](images/bot-paletteer-post2.png) ] --- .center[ # Discoverability ] -- .pull-left[ ## Pros - All palettes in one place - Consistent API ] -- .pull-right[ ## Cons - Hard to discover new palettes - Hard to find similar palettes - Hard to search for palettes ] --- # {paletteer} v1.0.0 ![](images/complete1.gif) --- # {paletteer} v1.0.0 ```r plot(paletteer_d("wesanderson::GrandBudapest2")) ``` <img src="index_files/figure-html/unnamed-chunk-5-1.png" width="700px" style="display: block; margin: auto;" /> --- # {paletteer} v1.0.0 ```r plot(paletteer_c("viridis::magma", 10)) ``` <img src="index_files/figure-html/unnamed-chunk-6-1.png" width="700px" style="display: block; margin: auto;" /> --- # {paletteer} v1.0.0 ```r plot(paletteer_c("ggthemes::Blue-Green Sequential", 256)) ``` <img src="index_files/figure-html/unnamed-chunk-7-1.png" width="700px" style="display: block; margin: auto;" /> --- .center[ # palette2vec ] -- # Proposed plan -- - Develop a method that projects color into a multi-dimensional space --- .center[ # palette2vec ] # Proposed plan - Develop a method that projects color into a multi-dimensional space - Use embedded color-palette space to find clusters, similarities and neighbors --- .center[ # palette2vec ] # Proposed plan - Develop a method that projects color into a multi-dimensional space - Use embedded color-palette space to find clusters, similarities and neighbors - Develop method to generate color palette from point in embedded space --- ## color palette similarity .pull-left[ ![](images/color-pair1.png) ] .pull-right[ <br> ### Similar colors used ### Not same saturation ] --- ## color palette similarity .pull-left[ ![](images/color-pair2.png) ] .pull-right[ <br> ### Same color ### Different lengths ] --- ## color palette similarity .pull-left[ ![](images/color-pair3.png) ] .pull-right[ <br> ### Same feel ### Muted colors ] --- # Main problem <br> ## color palettes contains a varied number of colors <br> ## Each color can be represented in no less then 3 dimensions --- # Main problem ## No trivial way to project 3 by N matrices into a vector of fixed length --- ### RGB color space .center[ ![:scale 50%](images/rgb.png) ] --- ### HSL color space .center[ ![:scale 60%](images/hsl.png) ] --- ### CIELAB color space .center[ ![:scale 50%](images/cielab.gif) ] --- ## We will be using hand-crafted custom features - Number of colors - Linearity - Split linearity - Contains at least one color - Are all one color - Summary statistics of inter-color distances - Summary statistics of saturation - Summary statistics of lightness --- # Linearity
value
colors
0.758
0.938
0.987
0.924
--- # Linearity split
value
colors
0.818
1.000
0.999
0.952
--- ## At least one colors is green (lower is better)
value
colors
28.237
18.770
18.643
29.633
--- # All colors are green (lower is better)
value
colors
55.157
27.328
44.279
45.226
--- # All colors are red (lower is better)
value
colors
37.372
64.742
44.900
46.120
--- ### palette2vec ```r library(palette2vec) base_palettes <- list(terrain = terrain.colors(10), heat = heat.colors(16), topo = topo.colors(8)) palette2vec(base_palettes) ``` ``` ## # A tibble: 3 x 29 ## name n_cols linear linear_split min_dist max_dist mean_dist min_saturation ## <chr> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> ## 1 terr… 10 0.998 1.00 5.09 47.7 27.0 0 ## 2 heat 16 0.997 0.997 0.620 64.3 30.3 100 ## 3 topo 8 0.973 0.992 3.25 105. 53.9 100 ## # … with 21 more variables: max_saturation <dbl>, mean_saturation <dbl>, ## # min_lightness <dbl>, max_lightness <dbl>, mean_lightness <dbl>, ## # contains_min_red <dbl>, contains_min_orange <dbl>, ## # contains_min_yellow <dbl>, contains_min_green <dbl>, ## # contains_min_turqouise <dbl>, contains_min_blue <dbl>, ## # contains_min_purple <dbl>, contains_min_pink <dbl>, contains_all_red <dbl>, ## # contains_all_orange <dbl>, contains_all_yellow <dbl>, ## # contains_all_green <dbl>, contains_all_turqouise <dbl>, ## # contains_all_blue <dbl>, contains_all_purple <dbl>, contains_all_pink <dbl> ``` --- ```r palette2vec(paletteer_palettes()) ``` ``` ## # A tibble: 1,711 x 29 ## name n_cols linear linear_split min_dist max_dist mean_dist min_saturation ## <chr> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> ## 1 awto… 8 0.963 0.975 9.52 67.4 40.5 16.8 ## 2 awto… 8 0.688 0.749 25.9 89.8 47.6 0 ## 3 awto… 16 0.840 0.921 10.3 87.2 42.2 0 ## 4 awto… 4 0.998 1 10.5 62.4 32.3 0 ## 5 awto… 9 0.814 0.962 20.6 72.8 43.5 0 ## 6 awto… 6 0.674 1 27.4 73.3 47.8 54.1 ## 7 base… 10 0.857 0.889 15.6 77.0 41.1 20.9 ## 8 base… 10 0.820 0.827 13.4 83.9 45.3 28.0 ## 9 base… 10 0.791 0.736 11.8 79.4 43.9 35.3 ## 10 base… 10 0.823 0.975 15.9 88.8 46.4 41.5 ## # … with 1,701 more rows, and 21 more variables: max_saturation <dbl>, ## # mean_saturation <dbl>, min_lightness <dbl>, max_lightness <dbl>, ## # mean_lightness <dbl>, contains_min_red <dbl>, contains_min_orange <dbl>, ## # contains_min_yellow <dbl>, contains_min_green <dbl>, ## # contains_min_turqouise <dbl>, contains_min_blue <dbl>, ## # contains_min_purple <dbl>, contains_min_pink <dbl>, contains_all_red <dbl>, ## # contains_all_orange <dbl>, contains_all_yellow <dbl>, ## # contains_all_green <dbl>, contains_all_turqouise <dbl>, ## # contains_all_blue <dbl>, contains_all_purple <dbl>, contains_all_pink <dbl> ``` --- ### Using these features can we apply UMAP to see if we were able to capture the right things `umap_embedding()` will take a list of palettes and - calculate palette2vec - normalize features - project to 2d using UMAP - opens shiny app for exploration ```r umap_embedding(paletteer_palettes()) ``` --- ![](images/umap.gif) --- ![](images/nn1.png) --- ![](images/nn2.png) --- ![](images/nn3.png) --- ![](images/nn4.png) --- ![](images/nn5.png) --- ![](images/nn6.png) --- class: center, middle # Thank you! ###
[EmilHvitfeldt](https://github.com/EmilHvitfeldt/) ###
[@Emil_Hvitfeldt](https://twitter.com/Emil_Hvitfeldt) ###
[emilhvitfeldt](linkedin.com/in/emilhvitfeldt/) ###
[www.hvitfeldt.me](www.hvitfeldt.me) Slides created via the R package [xaringan](https://github.com/yihui/xaringan).