raivokolde / pheatmap

Pretty heatmaps
225 stars 83 forks source link

Plotting Three Continuous Palettes #92

Open atly2000 opened 1 year ago

atly2000 commented 1 year ago

I would like to plot a pheatmap for a dataframe with values ranging from -9.96 to 15. I want to center the white portion at the value of 10.

I was able to center the white portion, but the "midnightblue" range is very small. I expected more colors between -9.96 to 5.

How can I adjust my breaks?

image image

colors <- c(seq(minval, midblueval,by=0.01),seq(mid1,mid2,by=0.01),seq(max1,max2,by=0.01))
minval = log2(0.001) #-9.96
midblueval = (5+minval)/2 #-2.5
mid1=  8
mid2=  12

max1 =13
max2=15

len1=(midblueval-minval)/0.01  

len2=(mid2-mid1)/0.01
len3=(max2-max1)/0.01
my_palette <- c(colorRampPalette(colors = c("midnightblue","blue"))(len1),
                colorRampPalette(colors = c("blue", "white", "red"))(len2),
                colorRampPalette(colors = c("red","red4"))(len3)
)