Heatmap Colormaps!

colormaps visualization heatmap random-code-snippets

Examples of good colormaps to use for heatmaps, both divergent and incremental.

Robert M Flight true

Normal Incrementing Data

Nine times out of ten, you probably need just one of the {viridis} colormaps for values that are increasing in one direction. For example, correlation values that are all positive, or abundances from RNA-Seq, etc. If you want to use them with {ComplexHeatmap}, you do so like this:

# correlation example for 0 - 1
# imagine cor_vals is a set of correlation values
cor_start = 0
cor_end = 1
n_break = 20
viridis_map = circlize::colorRamp2(seq(cor_start, 
                                       length.out = n_break),

        col = viridis_map, 

Divergent Data

In this case, you have values where a central value is a natural point that you want to highlight things above and below that value. Examples include correlations that include negative and positive correlations, log-fold-changes above and below zero. In this case, I prefer the {scico} package with the vik colormap.

cor_start = -1
cor_end = 1
n_break = 20

scico_map = circlize::colorRamp2(seq(cor_start
                                     length.out = n_break),
                                              palette = "vik"))

        col = scico_map,

Other Colormaps?

Do you have other suggestions for colormaps, both incremental and divergent? Please let me know in the comments!


If you see mistakes or want to suggest changes, please create an issue on the source repository.


Text and figures are licensed under Creative Commons Attribution CC BY 4.0. Source code is available at https://github.com/rmflight/researchBlog_distill, unless otherwise noted. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".


For attribution, please cite this work as

Flight (2022, Jan. 31). Deciphering Life: One Bit at a Time: Heatmap Colormaps!. Retrieved from https://rmflight.github.io/posts/2022-01-31-heatmap-colormaps/

BibTeX citation

  author = {Flight, Robert M},
  title = {Deciphering Life: One Bit at a Time: Heatmap Colormaps!},
  url = {https://rmflight.github.io/posts/2022-01-31-heatmap-colormaps/},
  year = {2022}