Skip to content

elvasileiou/cols4all

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Colors for all!

The cols4all is a new R package for selecting color palettes. “Color for all” refers to our mission that colors should be usable for not just people with normal color vision, but also for people with color vision deficiency. Currently, this package contains palettes from several popular and lesser known color palette series: Color Brewer, Viridis, Kovesi, Paul Tol, Scico, Carto, Tableau and Wes Anderson. Own palettes series can be added as well.

categorical palettes) sequential palettes) diverging palettes)

Color palettes are well organized and made consistent with each other. Moreover, they are scored on several aspects: color-blind-friendliness, the presence of intense colors (which should be avoided), the overall aesthetic harmony, and how many different hues are used. Finally, for each color palette a color for missing values is assigned, which is especially important for spatial data visualization. Currently we support three types: categorical (qualitative) palettes, sequential palettes, and diverging palettes. In the near future, more palette types will be added, such as cyclic, bivariate, and hierarchical.

Installation

cols4all will be available on CRAN soon. Until then it can be installed using:

# install.packages("devtools")
devtools::install_github("mtennekes/cols4all")
getwd()
#> [1] "/home/mtes/git/cols4all"
devtools::load_all(".")
#> ℹ Loading cols4all
#> Loading required package: abind
#> Loading required package: colorspace

Get started

Navigation through the color palettes is easy via the gui shown above, which is started with:

library(cols4all)
# For the GUI, shiny, shinyjs, and kableExtra are required
# install.packages(c("shiny", "shinyjs", "kableExtra"))
c4a_gui()

Selecting a palette is easy:

# Select the palette "kelly" with 7 colors
c4a("kelly", 7)
#> [1] "#F3C300" "#875692" "#F38400" "#A1CAF1" "#BE0032" "#C2B280" "#848482"

# find names of hcl palettes that are diverging
c4a_palettes(type = "div", series = "hcl")
#>  [1] "hcl.blue_red"     "hcl.blue_red2"    "hcl.blue_red3"    "hcl.red_green"   
#>  [5] "hcl.purple_green" "hcl.purple_brown" "hcl.green_brown"  "hcl.blue_yellow2"
#>  [9] "hcl.blue_yellow3" "hcl.green_orange" "hcl.cyan_magenta"

# select purple green palette from the hcl series:
c4a("hcl.purple_green", 11)
#>  [1] "#481F50" "#81488C" "#B473C1" "#D2A9DA" "#E7D3EC" "#F1F1F1" "#C7E0C9"
#>  [8] "#91C392" "#4D9D4E" "#256C26" "#013902"

# get the associated color for missing values
c4a_na("hcl.purple_green")
#> [1] "#818181"

Related R packages

The foundation of this package is another R package: colorspace. We use this package to analyse colors. For this purpose and specifically for color blind friendliness checks, we also use colorblindcheck.

There are a few other pacakges with a large collection of color palettes, in particular pals and paletteer. There are a few features that distinguishes cols4all from those packages:

  • Colors for missing values are made explicit. For this, either a greyscale color that is already contained in the palette is used, or a greyscale color is selected that is distinguisable, also for people with color vision deficiency.

  • Palettes are made consistent with each other. For instance, sequential palettes (except for spectral/rainbow palettes) all start with the lightest color and end with the darkest color. Furthermore, black and white are removed from most categorical palettes for practical reasons: white or light grey is almost always used as background color and black for annotation.

  • The GUI enables users to analyse characteristics of color palettes, such as color-blind-friendliness, harmony, and the presence of intense colors.

  • There is native support for ggplot2 and tmap (as of the upcoming version 4).

  • It will be possible to submit an own series of color palettes.

Feedback welcome!

  • Is everything working as expected?

  • Do you miss certain palettes or series?

  • Do you have ideas for improvement how to measure palette properties?

Let us know! (via github issues)

About

Colors for all (R package)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • R 86.0%
  • Python 14.0%