Giter Club home page Giter Club logo

cols4all's Introduction

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, Wes Anderson, and Seaborn. Own palettes series can be added as well.

Categorical Sequential Diverging
Bivariate (seq x seq) Bivariate (seq x cat) Bivariate (seq x desaturated)

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 several types: categorical (qualitative) palettes, sequential palettes, diverging palettes, and bivariate palettes (divided into three subtypes).

Installation

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

# install.packages("devtools")
remotes::install_github("mtennekes/cols4all")

Getting started

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

library(cols4all)
c4a_gui()

Selecting a palette is easy:

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

# find names of hcl palettes that are diverging
c4a_palettes(type = "div", series = "hcl")
#>  [1] "hcl.blue_red1"    "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] "#492050" "#82498C" "#B574C2" "#D2A9DB" "#E8D4ED" "#F1F1F1" "#C8E1C9"
#>  [8] "#91C392" "#4E9D4F" "#256C26" "#023903"

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

Overview of functions

Main functions:

  • c4a_gui GUI (shiny app) to see and analyse the palettes
  • c4a Get the colors of a palette

Palette names and properties:

  • c4a_palettes Get available palette names
  • c4a_series Get available series names
  • c4a_info Get palette information (such as type and maximum number of colors)
  • c4a_citation Show how to cite palettes (with bibtex code).
  • .P Environment via which palette names can be browsed with auto-completion (using $)

Importing and exporting palettes:

  • c4a_palettes_add Add color palettes
  • c4a_palettes_remove Remove color palettes
  • c4a_sysdata_import Import system data
  • c4a_sysdata_export Export system data

ggplot2

  • scale_<aesthetic>_<mapping>_c4a_<type> e.g. scale_color_continuous_c4a_div Add scale to ggplot2.

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)

cols4all's People

Contributors

helgasoft avatar mtennekes avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.