This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Changing font size in the key in heatmap.2

Hello,

Is there any way to change the font size of the x and y axis of the key histogram in heatmap.2?

Whenever I use cexCol and cexRow it only changes the font on the heatmap but not on the key

Thank you in advance

r heatmap heatmap.2

1 answer

From the docs

I think It will be a parameter added to key.par=list()

Possibly adding cex=, or cexCol= and cexRow= inside list()

 ## show how to customize the color key
 heatmap.2(x,
           key.par=list(mgp=c(1.5, 0.5, 0),
                        mar=c(2.5, 2.5, 1, 0),                               
                        cex=?????            # My insert, I think you can set your font size here
                        )
          )

Thank you for your answer. When running this I get this error:

Error in.External.graphics(C_layout, num.rows, num.cols, mat, as.integer(num.figures),  : 
  Incorrect state of graphics

Any idea of where this comes from?

Thanks

I think this is an Rstudio error, not your code.

  1. I seem to remember getting some graphics errors when my plot window was too small in RStudio i.e. not enough pixels to plot the data.... not sure if it was this error though....the fix was just increase the window size (drag it) and re-run
  2. Take a look at this post. It has a few suggestions including increasing window size. Also, resetting the graphics device with dev.off()

Log in to answer this question.