XiaoLuo-boy / ggheatmap

ggplot2 version of heatmap
81 stars 12 forks source link

Change legend labels #2

Open domenico-simone opened 2 years ago

domenico-simone commented 2 years ago

Hi,

thanks for this excellent package. I am plotting relative abundance data in a very wide range (1 to 50), therefore I am transforming my input matrix with the log10 function and then feed it to ggheatmap. But I would like anyway to have on the legend the true values instead of their log10 (e.g. 3, 10, 30 instead of 0.5, 1, 1.5). In a "pure" ggplot2 scenario I could do this with scale_color_continuous(breaks = c(0.5, 1, 1.5), labels = c(3, 10, 30)), but if I try to append it to a ggheatmap call, eg ggheatmap(...) + scale_color_continuous(breaks = c(0.5, 1, 1.5), labels = c(3, 10, 30)) I get a NULL object. Any suggestion about this?

Thank you

Domenico

XiaoLuo-boy commented 2 years ago

Thanks for your approval. I'm really sorry for replying to your question so late. As for your problem, I think you can extract a plotlist, and then use scale_color_continuous function. For example, p[[1]] <- p[[1]]+scale_color_continuous(breaks = c(0.5, 1, 1.5), labels = c(3, 10, 30)).