How to resize the size of cell in a heatmap via heatmap.2?
The main reason is the row label on the right of heatmap is not shown completely. Thank you.
How to resize the size of cell in a heatmap via heatmap.2?
The main reason is the row label on the right of heatmap is not shown completely. Thank you.
The size of each row is dependent on (A) how many rows there are and (B) how tall the image/window/whatever is. You can play around with margins a bit, but essentially if you need taller cells then either plot fewer of them or make the whole thing larger.
cexRow and cexCol are probably more helpful overall, but you can also modify the cell sizes using
For example, lhei = c(1,8) and lwid = c(0.5,4) will make the heatmap portion larger relative to the scale (which buys you a little extra space), where the first value is the legend size and the second value is the main heatmap size. If you are plotting dozens of genes, this might matter.
Specifiy cexRow
in the heatmap.2()
call to change the row label font size. For example:
> heatmap.2(..., cexRow=0.075, ...)
Likewise, specify cexCol
for column label font size.
I don't know of any way to automate this — it seems necessary to tweak per figure, depending on the number of rows and other features shown. A non-R tool like matrix2png
can make this is a little easier if you don't need clustering or dendrograms.
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
For your problem of showing the row labels on the right of the heatmap.2 add the argument "margins"
e.g.