I need to adjust the margins of my heatmap (especially at top and left).
I already kicked out color keys and headline, since they used most of my space. But now I'm left with blank space. I don't need that at top/left of my picture. I was using heatmap2
. I used a margin within the heatmap2 and a par-margin before the picture. But I'm not sure, how those interact. Furthermore I save my picture in svg and define weight/height here as well.
svg("mypic.svg", width=20, height=16)
par(mar=c(1,10,0.1,10))
heatmap.2(mat_data_round,
key = F,
cellnote = note,
notecol="black",
density.info="none",
trace="none",
margins =c(7,14),
col=colfun,
dendrogram="row",
Colv="NA",
cexRow=2,
cexCol=2)
What I expect is to not show white/blank space.
Source
The code is (mainly) inspired by
https://de.wikipedia.org/wiki/Datei:Gdp_to_debt_ratio.svg
I try to adjust and update things like this.
Solution
There was a small clash with the proposed solution. I had to remove main
in order to make it work. The following code drops the dendrogram feature, which is fine. Row and Column labels are readable with predefined width and height of my final svg. Thank you very much
svg("myheatmap.svg", width=20, height=16)
heatmap.2(mat_data_round,
key = F,
dendrogram = "none",
trace = "none",
cellnote = note,
notecol="black",
col=colfun,
Colv="NA",
lwid = c(0.2,5),
lhei = c(0.2,5),
margins =c(7,14),
cexRow=2,
cexCol=2)