ropensci / iheatmapr

Complex, interactive heatmaps in R
https://docs.ropensci.org/iheatmapr
Other
267 stars 35 forks source link

integration with viridis package #25

Open alpreyes opened 6 years ago

alpreyes commented 6 years ago

You instructed me in a previous answer how to change the default color scale of iheatmapr using RColorBrewer palettes. Is there a way to to use the color palettes in the R package "virids" (https://github.com/sjmgarnier/viridis)?

AliciaSchep commented 6 years ago

Hi @alpreyes There is no automatic integration with viridis package, but you can use those palettes as follows:

mat <- matrix(rnorm(20), ncol = 5, nrow = 4)
main_heatmap(mat, colors = viridis::viridis(12))

The colors argument can take a vector of colors. That vector can be generated using functions from viridis package. I chose n = 12 as number of colors above, but it gives pretty similar results with various n values of 5+ (there may be a right answer as to the number of colors based on how the viridis scales are constructed, but don't know at the moment).