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:
Gene
A nice way for creating discrete color breaks is given in question 59516054
.
Given the offered Z_Breaks
function, you can center the colorbar
tick labels in the middle of each box by using the function:
tickpos <- function(nFactor) {
pos <- unique((head(Z_Breaks(nFactor), -1)) + head(Z_Breaks(nFactor))[2] / 2) * (nFactor - 1)
}
and then assigning it to the tickval
argument of colorbar
:
colorbar <- list(tickvals = tickpos(nFactor), ticktext = names(colours))