将Y轴放在热图的左侧?

Jam*_*mes 9 graphics r heatmap

如何使用左侧的Y轴标签制作热图?它似乎默认为正确.我是否需要使用自定义轴axis()

42-*_*42- 9

在该heatmap功能中,轴的位置是硬编码的.但是只更改一个数字就可以很容易地将它定位在另一侧.在控制台上键入"heatmap",并在第二个axis()调用中将第一个参数从4更改为2 .

我改变的是:

axis(2, iy, labels = labRow, las = 2, line = -0.5, tick = 0,  # the 2 used to be 4
         cex.axis = cexRow)
Run Code Online (Sandbox Code Playgroud)

仍需要改变边距以适应开关.将当前值0更改为5似乎在我从帮助页面播放的示例中创建了足够的空间:

...
par(mar = c(margins[1L], 5, 0, margins[2L]))
Run Code Online (Sandbox Code Playgroud)

这是我的测试用例:

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\")")
Run Code Online (Sandbox Code Playgroud)