-
Notifications
You must be signed in to change notification settings - Fork 139
/
README.Rmd
608 lines (452 loc) · 20.6 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include=FALSE}
library(knitr)
opts_chunk$set(echo = FALSE, cache = TRUE, fig.width = 7,
fig.path = "man/figures/README-")
knit_hooks$set(optipng = hook_optipng)
opts_chunk$set("optipng" = "-o5")
```
```{r include=FALSE}
library(paletteer)
source("R/list_plotter.R")
```
# Comprehensive list of color palettes in r
The goal of this repository is to have a one stop destination for anyone looking for a color palette to use in r. If you would like to help/contribute please feel free post an issue, PR or send a email to [[email protected]](mailto:[email protected]).
# Interactive Color Picker at [https://emilhvitfeldt.github.io/r-color-palettes/](https://emilhvitfeldt.github.io/r-color-palettes/)
Further down the page is all the palettes available in the R ecosystem ordered alphabetically by package name. A list of palettes ordered by type can be found here [Type sorted palettes](type-sorted-palettes.md) to shorten the length of this page.
## Paletteer package
I have collected all the palettes displayed here in a single package using a unified framework. Developmental version can be found [here](https://github.com/EmilHvitfeldt/paletteer).
You can install the released version of paletteer from [CRAN](https://CRAN.R-project.org) with:
```{r, eval=FALSE}
install.packages("paletteer")
```
If you want the development version instead then install directly from GitHub:
```{r, eval=FALSE}
# install.packages("devtools")
devtools::install_github("EmilHvitfeldt/paletteer")
```
Table of Contents
=================
* [Main page](#comprehensive-list-of-color-palettes-in-r)
* [Blogposts and other resources](#blogposts-and-other-resources)
* [Color manipulation packages](#color-manipulation-packages)
* [Generative packages](#generative-packages)
* [Perception of color palettes](#perception-of-color-palettes)
* [Printing in black and white](#printing-in-black-and-white)
* [Color blindness](#color-blindness)
* [Honorable mentions](#honorable-mentions)
* [Palettes sorted by Package (alphabetically)](#palettes-sorted-by-package-alphabetically)
* [Sequential color palettes](type-sorted-palettes.md#sequential-color-palettes)
* [Diverging color palettes](type-sorted-palettes.md#diverging-color-palettes)
* [Qualitative color palettes](type-sorted-palettes.md#qualitative-color-palettes)
* [Canva palettes](canva.md)
* [Palettetown palettes](palettetown.md)
* [News](NEWS.md)
## Blogposts and other resources
Here is a collection of material on the use and creation of color palettes in r.
- [Creating corporate colour palettes for ggplot2](https://drsimonj.svbtle.com/creating-corporate-colour-palettes-for-ggplot2)
- [Make your own color palettes with paletti](https://edwinth.github.io/blog/paletti/)
- [How to create a color palette in R with more than 15 colors with ggplot2 ](https://github.com/duttashi/visualize/issues/19)
- [Generating a Custom Color Palette Function in R](https://quantdev.ssri.psu.edu/tutorials/generating-custom-color-palette-function-r)
- [How to build a color palette from any image with R and k-means algo](http://www.milanor.net/blog/build-color-palette-from-image-with-paletter/)
- [Why choice of colour is important beyond aesthtic considerations and how the quality of a palette might be assesed](https://www.data-imaginist.com/2018/scico-and-the-colour-conundrum/)
- [Viz palette: colors in action](http://projects.susielu.com/viz-palette)
## Color manipulation packages
- [Extract palettes from images and text](https://github.com/EmilHvitfeldt/quickpalette)
- [Fast Vectorised Colour Conversion and Comparison](https://github.com/thomasp85/farver)
- [How to Read, Inspect, and Manipulate Color Swatch Files](https://github.com/hrbrmstr/swatches)
- [Simple colour manipulation in R](https://github.com/jonclayden/shades)
## Generative packages
The purpose of this project is to showcase the palettes already available in R (packages). However sometimes you have to resort to make one yourself. When that is the case the following packages aides in creating.
- [AndreaCirilloAC/paletter](https://github.com/AndreaCirilloAC/paletter)
- [jolars/qualpalr](https://github.com/jolars/qualpalr)
- [ronammar/randomcoloR](https://github.com/ronammar/randomcoloR)
- [johnbaums/hues](https://github.com/johnbaums/hues)
- [ColorPalette](https://cran.r-project.org/web/packages/ColorPalette/index.html)
- [oaColors](https://cran.rstudio.com/web/packages/oaColors/index.html)
- [earthtones](https://cran.r-project.org/web/packages/earthtones/index.html)
- [leeper/colourlovers](https://github.com/leeper/colourlovers)
When creating color palettes certain website have also provided valuable
- [paletton](http://paletton.com/)
- [Data color picker](https://learnui.design/tools/data-color-picker.html)
- [i want hue](http://tools.medialab.sciences-po.fr/iwanthue/)
- [Viz Palette](http://projects.susielu.com/viz-palette)
## Perception of color palettes
Selecting a color palette requires a number of different considerations. Within these considerations is
- the palette retains its integrity when printed in black and white
- people with colorblindness are able to understand it
In the following I have outlined a couple of those problems
### Printing in black and white
While most of the palettes presented here contains a wide variety of colors. While that is compelling, you need to remember that your product might be printed in black and white one day, and you should pick a palette that allows for interpretation if that is the case.
First example is the `rainbow` palette from the `grDevices` package with its colorful display. However as we see here would it be horrible if used for black and white printing since different colors are mapped to the same shade of grey.
```{r, fig.height=3}
pal_data <- list(names = c("Normal", "desaturated"),
color = list(rainbow(32),
colorspace::desaturate(rainbow(32))))
list_plotter(pal_data$color, pal_data$names, "Normal rainbow palette")
```
A related problem happens with the standard color palette used in `ggplot2` since that color is picked to have constant chroma and luminance thus yielding the same shade of grey when desaturated. (This palette is no longer the default for continuous variables in `ggplot2` after version 3.0.0)
```{r fig.height=3}
pal_data <- list(names = c("Normal", "desaturated"),
color = list(scales::hue_pal()(256),
colorspace::desaturate(scales::hue_pal()(256))))
list_plotter(pal_data$color, pal_data$names, "Standard color palette for ggplot2")
```
One of the continuous palette that satisfy this criteria is the well known `viridis` palettes.
```{r fig.height=3}
pal_data <- list(names = c("Normal", "desaturated"),
color = list(viridis::inferno(256),
colorspace::desaturate(viridis::inferno(256))))
list_plotter(pal_data$color, pal_data$names, "viridis::inferno")
```
To test if the palette you want to use will be distorted when in black and white, use the `colorspace::desaturate()` to desaturate it.
### Color blindness
Another thing you have to take into consideration when picking a palette is how it would be viewed by a person who is [color blind](https://en.wikipedia.org/wiki/Color_blindness). There are several approaches to ensuring that a colorblind person can interpret your figures. A very good summary of what you can do is given by Masataka Okabe and Kei Ito in their document ["Color Universal Design (CUD) - How to make figures and presentations that are friendly to Colorblind people"](http://jfly.iam.u-tokyo.ac.jp/color/). Beyond using shapes, linetypes and size for information coding, which is easily done using the [ggplot2 aesthetics](https://ggplot2.tidyverse.org/reference/aes_linetype_size_shape.html), they recommend:
#### Using unambiguous palettes
The easiest way to make color coding accessible to everyone, is using a palette, that is unambiguous to people with various types of color blindness. There are a few available:
* Masataka Okabe and Kei Ito have developed such a [barrier free palette](http://jfly.iam.u-tokyo.ac.jp/color/#pallet), and you can use it in R with the [colorblind_pal() of the `ggthemes` package](https://jrnold.github.io/ggthemes/reference/colorblind.html) (also see colorblind_pal palette among the ggthemes palettes in the alphabetical list below) or by using the encoding provided by the [Cookbook for R](http://www.cookbook-r.com/Graphs/Colors_(ggplot2)/#a-colorblind-friendly-palette).
* Some of the palettes developed by Cynthia Brewer for the [ColorBrewer](http://colorbrewer2.org) are colorblind safe, you can find them through the [palette chooser website's button "colorblind safe"](http://colorbrewer2.org). In R, you can use the brewer palettes through [`ggplot2`'s scale_colour_brewer() et al.](https://ggplot2.tidyverse.org/reference/scale_brewer.html) or through the separate package [`RColorBrewer`](https://cran.r-project.org/web/packages/RColorBrewer/index.html).
#### Simulating effects of color blindness on used palettes
To visualize the effect of color blindness on our palettes we will turn to two packages. The `dichromat` package can simulate color blindness on individual color and then also entire palettes like so in this `rainbow` palette:
```{r}
pal_data <- list(names = c("Normal", "deuteranopia", "protanopia", "tritanopia"),
color = list(rainbow(256),
dichromat::dichromat(rainbow(256), type = "deutan"),
dichromat::dichromat(rainbow(256), type = "protan"),
dichromat::dichromat(rainbow(256), type = "tritan")))
list_plotter(pal_data$color, pal_data$names, "The effect of color blindness on the rainbow palette")
```
Another package that can provide helpful is the amazing [colorblindr](https://github.com/clauswilke/colorblindr) package that is able to simulate color blindness to `ggplot` objects them self.
## Honorable mentions
Due to the somehow vague notion of "color palette" have I decided to exclude certain kinds of packages from the main gallery. [Generative package](#generative-packages) have been discussed earlier.
### cpt-city
The amazing [cpt-city](http://soliton.vm.bytemark.co.uk/pub/cpt-city/index.html) is a wonderful project of creating an archive of color palettes to be used in cartography, technical illustration and design. Due to the immense size (7140) I have decided to refer to it instead of re-illustration them in this repository. If any of the palettes found here are for your liking they can be accessed in R using the following [package](https://cran.r-project.org/web/packages/cptcity/index.html):
```{r eval=FALSE, echo=TRUE}
# CRAN version
install.packages("cptcity")
```
### sport colors
Many of the palettes in sports related palettes have a very limited number of colors (often only 2 colors). This leads to quite low usability outside of the special area of sports analytic.
- [colorr](https://cran.r-project.org/web/packages/colorr/index.html)
Color palettes for EPL, MLB, NBA, NHL, and NFL teams.
- [beanumber/teamcolors](https://github.com/beanumber/teamcolors)
An R package providing color palettes for pro sports teams.
### Canva palettes
The `ggthemes` package include the 150 four-color palettes from the [canva.com](canva.com). Doe to the size and limited number of colors in the palettes these palettes will be featured on their own page and only once.
- [Canva colors](canva.md)
## Palettes sorted by Package (alphabetically)
```{r awtools, fig.height=6}
package_name <- "awtools"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# Developmental version
devtools::install_github("awhstin/awtools")
```
```{r cartography, fig.height=17}
package_name <- "cartography"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# Developmental version
devtools::install_github("riatelab/cartography")
# CRAN version
install.packages("cartography")
```
```{r dichromat, fig.height=18}
package_name <- "dichromat"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# CRAN version
install.packages("dichromat")
```
```{r dutchmasters, fig.height=7}
package_name <- "dutchmasters"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# Developmental version
devtools::install_github("EdwinTh/dutchmasters")
```
```{r ggsci, fig.height=43}
package_name <- "ggsci"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# Developmental version
devtools::install_github("road2stat/ggsci")
# CRAN version
install.packages("ggsci")
```
```{r ggpomological, fig.height=3}
package_name <- "ggpomological"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# Developmental version
devtools::install_github("gadenbuie/ggpomological")
```
```{r ggthemes, fig.height=73}
package_name <- "ggthemes"
pal_data_1 <- all_names(package_name)
pal_data_2 <- all_names("ggthemes_ptol")
pal_data_3 <- all_names("ggthemes_solarized")
pal_data <- list(names = c(pal_data_1$names,
pal_data_2$names,
pal_data_3$names),
color = c(pal_data_1$color,
pal_data_2$color,
pal_data_3$color))
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# Developmental version
devtools::install_github("jrnold/ggthemes")
# CRAN version
install.packages("ggthemes")
```
```{r ghibli, fig.height=28}
package_name <- "ghibli"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# Developmental version
devtools::install_github("ewenme/ghibli")
# CRAN version
install.packages("ghibli")
```
```{r grDevices, fig.height=7}
package_name <- "grDevices"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# CRAN version
install.packages("grDevices")
```
```{r jcolors-discrete, fig.height=14}
package_name <- "jcolors"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r jcolors-contin, fig.height=9}
package_name <- "jcolors"
palette_names <- c("default", "pal2", "pal3", "pal4", "pal10", "pal11", "pal12", "rainbow")
pal_data <- list(names = palette_names,
color = purrr::map(palette_names, ~ jcolors::jcolors_contin(palette = .x)(256)))
list_plotter(pal_data$color, pal_data$names, "jcolors (continuous)")
```
the `jcolors` continuous palettes are currently not available in the `paletteer` package.
```{r eval=FALSE, echo=TRUE}
# Developmental version
devtools::install_github("jaredhuling/jcolors")
# CRAN version
install.packages("jcolors")
```
```{r LaCroixColoR, fig.height=22}
package_name <- "LaCroixColoR"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# Developmental version
devtools::install_github("johannesbjork/LaCroixColoR")
```
```{r NineteenEightyR, fig.height=13}
package_name <- "NineteenEightyR"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# Developmental version
devtools::install_github("m-clark/NineteenEightyR")
```
```{r nord, fig.height=17}
package_name <- "nord"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# Developmental version
devtools::install_github("jkaupp/nord")
# CRAN version
install.packages("nord")
```
```{r ochRe, fig.height=17}
package_name <- "ochRe"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# Developmental version
devtools::install_github("ropenscilabs/ochRe")
# CRAN version
install.packages("ochRe")
```
```{r oompaBase, fig.height=9}
package_name <- "oompaBase"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# CRAN version
install.packages("oompaBase")
```
```{r palettetown, fig.height=11}
ids <- c(6, 17, 114, 137, 156, 191, 193, 283, 311, 318)
package_name <- "palettetown"
pal_data <- all_names(package_name)
list_plotter(pal_data$color[ids], pal_data$names[ids], package_name)
```
```{r eval=FALSE, echo=TRUE}
# Developmental version
devtools::install_github("timcdlucas/palettetown")
# CRAN version
install.packages("palettetown")
```
```{r palr, fig.height=5}
package_name <- "palr"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# Developmental version
devtools::install_github("AustralianAntarcticDivision/palr")
# CRAN version
install.packages("palr")
```
```{r pals, fig.height=36}
package_name <- "pals"
pal_data <- all_names(package_name)
ids <- !stringr::str_detect(pal_data$names, "kovesi")
list_plotter(pal_data$color[ids], pal_data$names[ids], package_name)
```
```{r eval=FALSE, echo=TRUE}
# Developmental version
devtools::install_github("kwstat/pals")
# CRAN version
install.packages("pals")
```
```{r palskovesi, fig.height=51}
package_name <- "pals"
pal_data <- all_names(package_name)
ids <- stringr::str_detect(pal_data$names, "kovesi")
list_plotter(pal_data$color[ids], pal_data$names[ids], package_name)
```
```{r eval=FALSE, echo=TRUE}
# Developmental version
devtools::install_github("kwstat/pals")
# CRAN version
install.packages("pals")
```
```{r Polychrome, fig.height=8}
package_name <- "Polychrome"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# CRAN version
install.packages("Polychrome")
```
```{r quickpalette, fig.height=18}
package_name <- "quickpalette"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# Developmental version
devtools::install_github("EmilHvitfeldt/quickpalette")
```
```{r rcartocolor, fig.height=35}
package_name <- "rcartocolor"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# Developmental version
devtools::install_github("Nowosad/rcartocolor")
# CRAN version
install.packages("rcartocolor")
```
```{r RColorBrewer, fig.height=36}
package_name <- "RColorBrewer"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# CRAN version
install.packages("RColorBrewer")
```
```{r Redmonder, fig.height=42}
package_name <- "Redmonder"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# CRAN version
install.packages("Redmonder")
```
```{r RSkittleBrewer, fig.height=6}
package_name <- "RSkittleBrewer"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# Developmental version
devtools::install_github("alyssafrazee/RSkittleBrewer")
```
```{r scico, fig.height=18}
package_name <- "scico"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# Developmental version
devtools::install_github("thomasp85/scico")
# CRAN version
install.packages("scico")
```
```{r viridis, fig.height=6}
package_name <- "viridis"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# Developmental version
devtools::install_github("sjmgarnier/viridis")
# CRAN version
install.packages("viridis")
```
```{r wesanderson, fig.height=16}
package_name <- "wesanderson"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# Developmental version
devtools::install_github("karthik/wesanderson")
# CRAN version
install.packages("wesanderson")
```
```{r yarrr, fig.height=22}
package_name <- "yarrr"
pal_data <- all_names(package_name)
list_plotter(pal_data$color, pal_data$names, package_name)
```
```{r eval=FALSE, echo=TRUE}
# Developmental version
devtools::install_github("ndphillips/yarrr")
# CRAN version
install.packages("yarrr")
```