This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Increase the size of legend in pheatmap

Hi,

I was using the pheatmap to cluster all the samples and do the visualization, but i was confused that how to increase the size legend which shows like that.

Thank you so much.

Snipaste 2018 08 03 15 39 23

rna-seq heatmap r

try increasing plot area. For any such questions, posting example data and code will help people to understand issue and post answer @ biologo

To continue with @cpad0112's answer, you can try;

pheatmap(, cellwidth=x, cellheight=y)

where x and y values you can play around to find the best size.

THKs,i tried it, but seems doesn't work

sorry, it;s my fault. i try many ways to increase the size of legend(not the label), but all faild. the code like:

pheatmap(data,
         method = c("pearson"),
         clustering_method = "complete",
         cellwidth = 80, 
         cellheight = 80,
         treeheight_row = 400,
         treeheight_col = 400,
         cluster_row = T,
         cluster_col = T,
         show_rownames = T,
         show_colnames = T,
         cex = 2.5,
         legend = T,
         fontsize = 10,
         legend_breaks = 0:1,
         color = colorRampPalette(brewer.pal(9,"Reds"))(400),
         border_color = "NA")

1 answer

Take a back up of your code posted above, and try plotting with this basic code (OP code). If you can see the legend, then keep optimizing heatmap. I think unoptimized cell and other parameters are issue here in code (as data is not furnished) :

pheatmap(data,
         method = c("pearson"),
         clustering_method = "complete",
         treeheight_row = 40,
         treeheight_col = 40,
         cluster_row = T,
         cluster_col = T,
         show_rownames = T,
         show_colnames = T,
         legend = T,
         fontsize = 10,
         color = colorRampPalette(brewer.pal(9,"Reds"))(400))

thank you very much, it works well now

Log in to answer this question.