【发布时间】:2014-01-15 19:10:22
【问题描述】:
我正在尝试创建一个与条形图相结合的热图,以便在每一行的末尾都有一个长度与该行相关的条形图。这个想法是将以下两者合二为一:
library(gplots)
data(mtcars)
x <- as.matrix(mtcars[,2:11])
hm<-heatmap(x)
barplot(mtcars[hm$rowInd,"mpg"],horiz=T,names.arg=row.names(mtcars)[hm$rowInd],las=2,cex.names=0.7,col="purple",2)
我的问题是如何在使行和条对齐的同时将两者结合起来? 谢谢。
【问题讨论】:
-
你没有包括你的问题...
-
我不知道你在树状图上的设置如何,但这里的问题是
heatmap() uses layout and draws the image in the lower right corner of a 2x2 layout. Consequentially, it can not be used in a multi column/row layout, i.e., when par(mfrow = *) or (mfcol = *) has been called.我建议使用 ggplot2 进行热图和条形图。一个很好的例子可以在这里找到:learnr.wordpress.com/2010/01/26/ggplot2-quick-heatmap-plotting。如果您需要更多帮助,请告诉我。 -
@amzu 这听起来像是一个答案,不是吗?
-
作为答案发布,谢谢@Amanda