Entering edit mode
5.5 years ago
Ming
▴
110
Dear All,
I am trying to plot a heatmap with the heatmap.2 function, but I am not getting any color on my Color Key.
The following are my code:
col1 <- colorRampPalette(c("green", "black", "red"))(499)
> col_breaks = c(seq(0, 0.002, length = 50),
> seq(0.0021, 0.004, length = 50),
> seq(0.0041, 0.006, length = 50),
> seq(0.0061, 0.008, length = 50),
> seq(0.0081, 0.01, length = 50),
> seq(0.011, 0.04, length = 50),
> seq(0.041, 0.08, length = 50),
> seq(0.081, 1.2, length = 50),
> seq(1.21, 1.4, length = 50),
> seq(1.41, 1.6, length = 50))
heatmap.2(data.matrix(MTB_genus_RA_T), scale = "none", trace = "none", density.info = "density", col = col1, breaks = col_breaks, Rowv = as.dendrogram(row.clus), Colv = as.dendrogram(col.clus.MTB), margins = c(13, 8), main = "Heatmap of MTB at the genus level", cexRow = 1.1, cexCol = 1.1, keysize = 2, # key.par=list(mar=c(bottom, left, top, right)) key.par=list(mar=c(3,5,4,5)))#, lhei = c(0.1, 0.1), lwei = c(0.1, 0.1))
I am not getting any color on my color key. Can anyone please help?
Thank you!
Perhaps provide an example with a more complete dataset?
Many of your objects (e.g. MTB*) were not included - so we cannot say for sure whether this is a problem that is specifically happening to you or if it is reproducible for others.
Dear @benformatics, what other kind of information will you like?
Why not replace
col = col1, breaks = col_breaks,
with justcol = greenred,
? Depending on your purpose, but it seems the values are from 0 to ~1.5 instead of something like -3 to 3 (perhaps using a sequential palette here, for example,brewer.pal(9, "YlGnBu")
, would be better).Dear @SMK, how would you change the code?
Hi Ming,
Something like: