colorBlindSafePal {biovizBase} | R Documentation

## Color blind safe palette generator

### Description

This function help users create a function based on specified color blind safe palette. And the returned function could be used for color generation.

### Usage

    genDichromatPalInfo()
    genBrewerBlindPalInfo()
    genBlindPalInfo()
    colorBlindSafePal(palette)
    blind.pal.info
    brewer.pal.blind.info
    dichromat.pal.blind.info

### Arguments

`palette` | A index numeric value or character. Please see `blind.pal.info`, the palette could be "pal_id" or names the row in which users could specify the palette you want to use.

### Details

We get those color-blind safe palette based on http://colorbrewer2.org/ and http://geography.uoregon.edu/datagraphics/color_scales.htm those color are implemented in two packages, RColorBrewer and dichromat. But RColorBrewer doesn't provide subset of color-blind safe palette info. And dichromat doesn't group color based on "quality", "sequential" and "divergent", so we pick those color manually and create a combined palette, blind.pal.info.

`colorBlindSafePal` will return a function, this function will take two arguments, `n` and `repeatable`. if n is smaller than 3(n >= 3 is required by RColorBrewer), we use 3 instead and return a color vector. If n is over the `maxcolors` column in blind.pal.info, we use `maxcolors` instead when `repeatable` set to `FALSE`, if `repeatable` set to `TRUE` we repeat the color of all the allowed colors(length equals `maxcolors`) in the same order. This has special case in certain graphics which is always displayed side by side and don't worry about the repeated colors being neighbors.

`genBrewerBlindPalInfo` return `brewer.pal.blind.info` data frame containing all color-blind safe palettes from `brewer.pal.info` defined in RColorBrewer, but it's not only just subset of it, it also changes some `maxcolors` info.

`genDichromatPalInfo` return `dichromat.pal.blind.info` data frame.

`genBlindPalInfo` return `blind.pal.info` data frame.

### Value

A color generating function with arguments `n` and `repeatable`. `n` specifying how many different discrete colors you want to get from them palette, and if repeatable turned on and set to TRUE, you can specify n even larger than maximum color. The color will be repeated following the same order.

### Author(s)

Tengfei Yin

### Examples

    ## Not run:
    library(scales)
    ## brewer subse of only color blind palette
    brewer.pal.blind.info
    genBrewerBlindPalInfo()
    ## dichromat info
    dichromat.pal.blind.info
    genDichromatPalInfo()
    ## all color blind palette, adding id/pkg.
    blind.pal.info
    ## with no parameters, just return blind.pal.info
    colorBlindSafePal()
    mypal <- colorBlindSafePal(20)
    ## or pass character name
    mypal <- colorBlindSafePal("Set2")
    mypal12 <- colorBlindSafePal(22)
    show_col(mypal(12, repeatable = FALSE)) # warning
    show_col(mypal(11, repeatable = TRUE))  # no warning, and repeat
    show_col(mypal12(12))

    ## End(Not run)

[Package biovizBase version 1.34.1 Index]