Some general suggestion

Background in color space

  1. RGB color space
    • Mixture of red, green and blue color
  2. HSB color space
  3. HSLuv
    • A alternative to HSL, claimed to be more human friendly

python for color space mapping

import colorsys
# convert rgb to hsv 
colorsys.rgb_to_hsv(0.2, 0.4, 0.4)
# (0.5, 0.5, 0.4)
colorsys.hsv_to_rgb(0.5, 0.5, 0.4)
# (0.2, 0.4, 0.4)

Some useful tricks

Color map for visualization

Color Map Requirements

  • According to Diverging Color Maps for Scientific Visualization – The map yields images that are aesthetically pleasing. – The map has a maximal perceptual resolution. – Interference with the shading of 3D surfaces is minimal. – The map is not sensitive to vision deficiencies. – The order of the colors should be intuitively the same for all people. – The perceptual interpolation matches the underlying scalars of the map

    Claasification of color maps

  • qualitative / nominal color maps: discrete, unordered classes
  • sequential / ordinal / saturation color maps: hue is nearly fixed, (nearly monochromatic), difference in saturation and lightness indicate numericial difference
  • diverging / ratio / bipolar / doubleended color maps: two major color components
  • cyclic: change in lightness of two different colors that meet in the middle and beginning/end at an unsaturated color

Collection of perceptually accurate colormaps

Caveats

Examples

Choose which type of color scale to use

  • qualitative: bar chart, violin plot, etc. To illustrate contrast, use complementary hues, to illustrate similarity, use analog hues.
  • sequential: indicates difference toward one direction, like expression level, frequency, etc
  • diverging: indicates difference toward two direction, like Z-score of differentially expressed genes

Customization of color maps

Qualitative

Sequential

  • Perceptually uniform cmap recommanded by seaborn here
    • rocket,mako,flare,crest,magma,viridis
  • Perceptually uniform cmap by matplotlib
    • viridis, plasma, inferno, magma, cividis

Diverging

  • seaborn
    • vlag,icefire
  • matplotlib
    • BrBG and RdBu are good options. coolwarm is a good option, but it doesn’t span a wide range of L values”

python examples

R example