iheatmapr icon indicating copy to clipboard operation
iheatmapr copied to clipboard

reverse color scale

Open alpreyes opened this issue 7 years ago • 2 comments

Is it possible to reverse the color scale in one-color gradients so that the darker color correspond to the to lower values and lighter colors correspond to greater values?

alpreyes avatar Jan 26 '18 18:01 alpreyes

This is possible, albeit a bit clunky at the moment. The colors argument to functions like main_heatmap and iheatmap can take in a vector of colors instead of a palette name. So you can do something like:

mat <- matrix(rnorm(20), ncol = 5, nrow = 4)  
main_heatmap(mat, colors = rev(RColorBrewer::brewer.pal(3,"Reds"))) 
# Can change 3 to higher number 
# rev function reverses order of the colors
# colors argument also works for iheatmap function

I'll keep this issue open as a note to either:

  1. Add more to docs to explain this possibility
  2. Possibly add something like a reverse_colorscale option in future

AliciaSchep avatar Jan 29 '18 04:01 AliciaSchep

Thank you, Alicia. This is greatly appreciated!

alpreyes avatar Jan 31 '18 01:01 alpreyes