I have a matrix
library(pheatmap)
set.seed(1)
mat <- matrix(rexp(200, rate=.001), ncol=20)
pheatmap(mat)
and there is one value that is much higher than the rest. Therefore, I would like to use a logarithmic scaling for the legend bar (1, 10, 100, 1000, ...).
Is there a possibility to do that with the pheatmap package?
EDIT: I don't want to make log(mat), I only want the color scaling bar be scaled logarithmic (1, 10, 100, 1000, ...).
Just add logarithmic legend_breaks and show a label for the maximum.
pheatmap::pheatmap(mat, legend_breaks=c(10^(0:ceiling(log10(max(mat)))),
round(max(mat), 2)))
Yielding

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With