我正在尝试创建heatmap
指标。我已经在SO上使用了多个问题来实现这一目标,但似乎我的解决方案是独一无二的。我有3个跟踪的列:OTD
,TAT
和DIH
。我希望每个列都有颜色中断,但我需要它们不同。
即。
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
似乎适用于整个地图,我不知道如何根据我的需要操作此功能。任何帮助将是欣赏。请参阅下面的输出代码和图片。
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)
下面的图片是输出。它没有我想要的颜色序列。