How to increase color intensity in colorramppalette

I use the pheatmap package in R to create heat maps of different data ... and using colorramppalette to create colors, but the colors are very bright.

I need dark colors, how can I do this?

here is the code:

hmcols<-colorRampPalette(c("white","red"))(256) pheatmap( test, color=hmcols, cluster_rows=FALSE, cluster_cols=FALSE, legend=TRUE, show_rownames=FALSE, show_colnames=FALSE, filename="a.png" ) 

How can I increase the color intensity in a colorramppalette or can I use any other Heatmap package that looks like pheatmap but produces dark color?

+4
source share
1 answer

Try using hcl and adjust the brightness steps. For instance:

 cols <- hcl(0,l=seq(1,100,length=11)) cols # [1] "#3F0000" "#470016" "#591D2D" "#6F3744" "#87505B" "#A06974" "#BB838D" "#D69DA8" # [9] "#F1B8C3" "#FFD4DE" "#FFF0FB" plot(1:11,cex=4,bg=cols,pch=21) 

There are many examples in the ?hcl section, and I'm sure you will find some color breaks that suit your needs.

If this doesn't suit your needs, you can also use some of the color scales found in the RColorBrewer package, which I highly recommend (check their excellent website for larger color scales) and interpolate colors with colorRampPalette using brewer.pal and maybe crop the end of the color scale.

You can also use a diverging color scale, again from RColorBrewer , rather than sequential. Here are some examples:

 require(RColorBrewer) par(mfrow=c(2,2)) cols <- colorRampPalette( colors = hcl(0,l=seq(1,100,length=11)) ) plot( 1:11 , cex = 4 , bg = cols(11) , pch = 21 , main = "HCL Colours") cols <- colorRampPalette( colors = rev(brewer.pal(9,"Reds")) ) plot( 1:11 , cex = 4 , bg = cols(11) , pch = 21 , main = "Sequential RColorBrewer palette") cols <- colorRampPalette( colors = rev(brewer.pal(9,"Reds"))[1:5] ) plot( 1:11 , cex = 4 , bg = cols(11) , pch = 21 , main = "Truncated sequential\nRColorBrewer palette" ) cols <- colorRampPalette( colors = brewer.pal(9,"RdBu") ) plot( 1:11 , cex = 4 , bg = cols(11) , pch = 21 , main = "Diverging RColorBrewer palette" ) 

enter image description here

+6
source

Source: https://habr.com/ru/post/1484743/


All Articles