.External.R中存在错误

.External.R中存在错误,r,heatmap,R,Heatmap,我使用下面的函数从48列X 32行的矩阵创建热图: heatmap.2(all.data,Rowv = FALSE, Colv = FALSE, trace="none",main="All data",col=colorRampPalette(c("green","yellow","red"))) 它给了我一些警告,因为删除了dendograms,但它仍然给了我想要的热图加上颜色键,发生了一些事情,现在当我尝试运行相同的程序时,它给了我没有颜色键的绘图和一个错误: Error in plot

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

heatmap.2(all.data,Rowv = FALSE, Colv = FALSE, trace="none",main="All data",col=colorRampPalette(c("green","yellow","red")))
它给了我一些警告,因为删除了dendograms,但它仍然给了我想要的热图加上颜色键,发生了一些事情,现在当我尝试运行相同的程序时,它给了我没有颜色键的绘图和一个错误:

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,但颜色键仍然没有出现在热图中,任何帮助都将非常感谢

算出了,这只是显示器的一个错误,如果我自动保存绘图而不是让RStudio向我显示,那么图形就正常了

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

如果您的绘图过去一直工作,现在抛出
无效图形状态
错误,请尝试通过调用
dev.off()
重置图形设备。这是由RStudio的帮助网站提出的

我是通过在堆叠窗口之前最大化窗口来实现的。

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

谢谢!应用dev.off()修复了我的问题。