Vinterwoo
Vinterwoo

Reputation: 3941

Color Bars from HeatMaps/ Heat Bars

I'd like to set up a plot with 3 bars of the same height (separated by white space), with each bar colored similar to a heat map (heat bar?). This would amount to cutting out single columns from 3 different color maps and lining them up next to each other.

I have 3 different data sets, that in the past of created heat maps for. Now I'd like to compare discrete columns, so the data in R would look like so:

V1<-c(1,1,4,4,5,6,6,2,4,5,15,16,15,6,7,8,7,6,3,4)
V2<-c(30,38,50,50,40,50,60,70,50,40,200,210,200,30,40,50,60,70,80,70)
V3<-c(300,340,500,500,500,550,540,500,540,500,900,999,980,490,400,500,500,2000,2000,2000)

DF<-data.frame(V1,V2,V3)

At row 11, each of the data sets experiences a sharp increase, and the hope is that the color bars will show this when lined up to each other. But V3 has some outlier data, so I will need constrain the color value scale so the change at row 11 is not washed out by the last 3 high values in V3.

Upvotes: 0

Views: 1326

Answers (1)

Joe
Joe

Reputation: 8601

Here's a suggestion: scale each variable to z-scores (SD above and below the mean), assign NA to your outliers and plot a 3-column heatmap with spaces between the columns. You can colour the outliers an unrelated colour.

DF[DF > 1000] <- NA 
library(gplots)
heatmap.2(scale(DF), Rowv = F, Colv = F, trace = "none", colsep = c(1:3), na.color = "Green")

This gives enter image description here

See ?heatmap.2 for other options.

Upvotes: 1

Related Questions