如何删除heatmap.2输出中的左侧空格

时间:2013-12-16 05:44:52

标签: r plot heatmap

使用此代码

 library(gplots)

 # Read data
 dat <- read.table("http://dpaste.com/1501148/plain/",sep="\t",header=T);
 rownames(dat) <- dat$Name
 dat <- dat[,!names(dat) %in% c("Name")]

 #Set colour
 hmcols <- rev(redgreen(2750));

 pdf("~/Desktop/tmp.pdf")

 # Plot the figure, we don't want KEY in the plot and no dendrograms also.
 heatmap.2(as.matrix(dat),Colv=FALSE,dendrogram="none",scale="row",col=hmcols,trace="none",  margin=c(5,15), lwid=c(1.5,2.0),key=FALSE);
 dev.off()

输出如下图: enter image description here

请注意,左侧有太多空白区域。 我该如何删除它? 原则上我想做整个热图的左对齐。

2 个答案:

答案 0 :(得分:7)

可以使用layout参数完成此操作:lheilwid,它们控制图的高度和宽度。

在您的情况下,请尝试:lwid=c(0.1,4), lhei=c(0.1,4)

有关如何在layout中使用heatmap.2参数的更多详细信息,请参阅此post

答案 1 :(得分:1)

在预览中打开它(这是在Mac上从路径判断)使用工具/选择工具/裁剪到所需的配置并复制/ cmd-C。然后从剪贴板文件/新建/:

enter image description here