Adding a continuous "wrap around" scale to heat map
1
0
Entering edit mode
15 months ago
Jen ▴ 80

I am aiming to create a heatmap similar to the one below.

enter image description here

I have successfully generated one that is satisfactory EXCEPT for the color scale (below). I used the code:

heatmap(Hallmark3, Colv = NA, Rowv = NA, scale="column", cexRow=.8, cexCol=1)

enter image description here

The coloring must indicate time of day so I would like it to be continuous and depict 0-24hrs. This is what they have done in the first heat map. I will also need to figure out how to add a legend showing the scale where it starts at 0 and ends at 24 (marking every 6hrs as in the first image). I think maybe I might have to do something indicating the scale represents radians or something along those lines but I am lost on how to get there.

r heatmap • 820 views
ADD COMMENT
2
Entering edit mode
15 months ago
LChart 4.6k

Just use a symmetrical color palette and pass it into the col= argument.

pal <- colorRampPalette(c('blue', 'brown', 'blue'))
plot(1:50, rep(1,50), col=pal(50), pch=16)

heatmap(..., col=pal(100))

The color bar needs to be added separately with a legend call, or you can switch to a more complete heatmap package such as ComplexHeatmap, Superheat or many others that add the color bar automatically.

ADD COMMENT
0
Entering edit mode

Thank you so much. That was very helpful :)

ADD REPLY

Login before adding your answer.

Traffic: 1717 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6