Using discrete custom color in a plotly heatmap
问题 I'm trying to generate a plotly heatmap , where I'd like the colors to be specified by a discrete scale. Here's what I mean: Generate data with 2 clusters and hierarchically cluster them: require(permute) set.seed(1) mat <- rbind(cbind(matrix(rnorm(2500,2,1),nrow=25,ncol=500),matrix(rnorm(2500,-2,1),nrow=25,ncol=500)), cbind(matrix(rnorm(2500,-2,1),nrow=25,ncol=500),matrix(rnorm(2500,2,1),nrow=25,ncol=500))) rownames(mat) <- paste("g",1:50,sep=".") colnames(mat) <- paste("s",1:1000,sep=".")