I am trying to create a heatmap
of metrics. I have used multiple questions on SO to get this far, but it seems like my solution is unique. I have 3 columns that I am tracking: OTD
, TAT
, and DIH
. I would like to have color breaks for each of these columns but I need them to be different.
I.e.
OTD Column: Red < 85, 85 <= Yellow < 90, Green >=90
TAT Column: Red > 16, 15 > Yellow <= 16, Green <= 15
DIH Column: Red > 27, 25 > Yellow <= 27, Green <= 25
col_breaks
seems to apply to the entire map, I am not sure how to manipulate this function to my needs. Any help would be appreciate. Please see below for code and picture of output.
Heat <- select(Shipments, Customer.Name, OTD, TAT, Total.TAT, Shipped.Qty)
Heat <- Heat[, list(OTD=mean(OTD),TAT=mean(TAT),DIH=mean(Total.TAT),Shipped=sum(Shipped.Qty)),by=Customer.Name]
Heat <- arrange(Heat, desc(Shipped))
Heat <- head(Heat,5)
Heat <- data.frame(Heat)
row.names(Heat) <- Heat$Customer.Name
Heat <- Heat[,2:4]
Heat$OTD <- Heat$OTD*100
Heat <- round(Heat,1)
Heat_matrix <- data.matrix(Heat)
my_palette <- colorRampPalette(c("#D20000","#F6FC00","#009A00"))(n = 299)
col_breaks <- c(seq())
heatmap.2(Heat_matrix,
cellnote = Heat_matrix,
notecol = "black",
notecex = 2,
trace = "none",
density.info = "none",
key = FALSE,
scale = "column",
margins = c(10,10),
col = my_palette,
dendrogram = "none",
Colv = FALSE,
Rowv = FALSE)
Picture below is the output. It does not have the color sequence that I want.