Open MySchizoBuddy opened 9 years ago
Option to add a legend would be great. Please add this feature.
+1.
+1
+1
+1
+1
+1 this is essential for the viewer to interpret the scale for the colour scheme used in the plot.
+1 would transform the utility of this for use in publications.
+1
+1
+1
+1
+1
Currently implements a color key and histogram and allows the passage of factors/characters/numbers as RowSideColors and ColSideColors. Will soon add labels for ColSideColors and RowSideColors. Issues welcome https://github.com/Alanocallaghan/d3heatmap
I thought I was clever... I thought use another heatmap as the legend of the heatmap! And in the process discovered that you can't make a heatmap out of a 1-row matrix (or df):
legendDF <- data.frame(a=3,b=2,c=1,d=0)
rownames(legendDF) <- "Legend"
d3heatmap(legendDF, dendrogram = 'none',
colors = c("#A8A8A8","#F9F200","#F40E00","#1FAE00"))
doesn't plot anything... but if I add another row:
legendDF <- data.frame(a=c(3,2),b=c(2,2),c=c(1,2),d=c(0,2))
rownames(legendDF) <- c("Legend","s")
d3heatmap(legendDF, dendrogram = 'none',
colors = c("#A8A8A8","#F9F200","#F40E00","#1FAE00"))
That works. OK, so lemme be sneaky:
d3heatmap(legendDF[1,], dendrogram = 'none',
colors = c("#A8A8A8","#F9F200","#F40E00","#1FAE00"))
Nope... fail.
The problem is due to how R treats 1-dimensional data.frames or matrices (no surprise there!).
The bug is in d3heatmap.R
line 243: x <- x[rowInd, colInd]
should be x <- x[rowInd, colInd, drop = FALSE]
I've resolved this in my fork (linked above)
Hello all,
The heatmaply R package is a new implementation of interactive cluster heatmaps in R which relies on the plotly R package. This is based on a fork of my work in d3heatmap.
The package is availabale from CRAN: https://cran.r-project.org/package=heatmaply
The feature you've requested is now available (as default) by using the following code:
library(heatmaply)
heatmaply(mtcars)
A heatmap legend shows the relationship between the colors used and the values.