将Y轴放在热图的左侧?
如何使用左侧的Y轴标签制作热图?它似乎默认为右侧.我是否需要使用 axis()创建自定义轴?
How do I make a heatmap with the Y axis labels on the left? It seems to default to the right. Do I need to make a custom axis using axis()?
在 heatmap 函数中,轴的位置是硬编码的.但是,仅更改一个数字以使其位于另一侧将非常容易.在控制台上键入"heatmap",然后在第二个 axis()调用中将第一个参数从4更改为2.
In the heatmap function the positions of the axes are hard-coded. But it would be very easy to change just a single number to get it positioned on the other side. Type "heatmap" at your console and change the first argument from a 4 to a 2 in the second axis() call.
我所做的只是:
axis(2, iy, labels = labRow, las = 2, line = -0.5, tick = 0, # the 2 used to be 4
cex.axis = cexRow)
仍然需要更改边距以适应开关.在我从帮助页面开始处理的示例中,将当前值从0更改为5似乎可以创建足够的空间:
There still need to be changes in the margins to accommodate the switch. Changing the current value of 0 to 5 seemed to create adequate space in the example I was playing with from the help page:
...
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\")")