15

我使用下面的函数从 48 列 X 32 行的矩阵创建热图:

heatmap.2(all.data,Rowv = FALSE, Colv = FALSE, trace="none",main="All data",col=colorRampPalette(c("green","yellow","red")))

由于删除了树状图,它给了我一些警告,但它仍然给了我想要的热图和颜色键,发生了一些事情,现在当我尝试运行相同的东西时,它给了我没有颜色键的情节和一个错误:

Error in plot.new() : figure margins too large
In addition: Warning messages:
1: In heatmap.2(all.data, Rowv = FALSE, Colv = FALSE, trace = "none",  :
  Discrepancy: Rowv is FALSE, while dendrogram is `both'. Omitting row dendogram.
2: In heatmap.2(all.data, Rowv = FALSE, Colv = FALSE, trace = "none",  :
  Discrepancy: Colv is FALSE, while dendrogram is `none'. Omitting column dendogram.

如果我将所有边的边距更改为 1:

par(mar=c(1,1,1,1))
heatmap.2(all.data,Rowv = FALSE, Colv = FALSE, trace="none",main="All data",col=colorRampPalette(c("green","yellow","red")))

再试一次,它不会制作热图并给我这个错误:

Error in .External.graphics(C_layout, num.rows, num.cols, mat, as.integer(num.figures),  : 
  invalid graphics state
In addition: Warning messages:
1: In heatmap.2(all.data, Rowv = FALSE, Colv = FALSE, trace = "none",  :
  Discrepancy: Rowv is FALSE, while dendrogram is `both'. Omitting row dendogram.
2: In heatmap.2(all.data, Rowv = FALSE, Colv = FALSE, trace = "none",  :
  Discrepancy: Colv is FALSE, while dendrogram is `none'. Omitting column dendogram.

我也尝试添加到功能键=T,但颜色键仍然没有出现在热图中,任何帮助将非常感激!!!

4

5 回答 5

50

如果您的绘图过去一直在工作并且现在抛出invalid graphics state错误,请尝试通过调用来重置图形设备dev.off()。这是由 RStudio 的帮助站点建议的。

于 2014-08-25T14:43:26.837 回答
8

想通了,这只是显示的错误,如果我自动保存绘图而不是让 RStudio 显示给我看,图表就可以了

于 2013-09-06T08:00:04.750 回答
3

我也在 RStudio 中发现了这个问题。它可以通过增加 RStudio 中绘图窗口的垂直大小来解决(否则部分绘图不适合窗口并发生错误)。

于 2014-02-27T00:32:28.317 回答
2

我通过在堆叠之前最大化窗口来做到这一点。

于 2015-04-25T13:17:15.647 回答
1

这是一个与 RStudio 相关的问题。如果增加显示面板,它应该可以正常工作。这是假设没有其他编码错误。

于 2018-09-11T14:21:32.273 回答