如何使用左侧的 Y 轴标签制作热图?它似乎默认为右侧。我需要使用自定义轴axis()
吗?
问问题
11009 次
1 回答
9
在heatmap
函数中,轴的位置是硬编码的。但是只需更改一个数字即可将其定位在另一侧非常容易。axis()
在您的控制台中键入“heatmap”,并在第二次调用中将第一个参数从 4 更改为 2 。
我改变的只是:
axis(2, iy, labels = labRow, las = 2, line = -0.5, tick = 0, # the 2 used to be 4
cex.axis = cexRow)
仍然需要更改边距以适应转换。在我从帮助页面玩的示例中,将当前值 0 更改为 5 似乎创造了足够的空间:
...
par(mar = c(margins[1L], 5, 0, margins[2L]))
这是我的测试用例:
x <- as.matrix(mtcars)
rc <- rainbow(nrow(x), start=0, end=.3)
cc <- rainbow(ncol(x), start=0, end=.3)
utils::str(hv) # the two re-ordering index vectors
## no dendrogram (nor color strip)
heatmap.new(x, Colv = NA, Rowv=NA, col = cm.colors(256), scale="column",
margins=c(5,2),
xlab = "specification variables", ylab= "Car Models",
main = "heatmap(<Mtcars data>, ..., scale = \"column\")")
于 2011-09-02T18:09:39.577 回答