.External.graphics 中的错误和图形边距太大

问题描述 投票:0回答:5

我使用下面的函数从 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,但颜色键仍然没有出现在热图中。怎么解决这个问题?

r rstudio heatmap
5个回答
54
投票

如果您的绘图过去一直有效,但现在抛出

invalid graphics state
错误,请尝试通过调用
dev.off()
重置图形设备。这是 RStudio 帮助网站建议的。


7
投票

想通了;这只是显示器的错误。如果我自动保存绘图而不是要求 RStudio 将其显示给我,则图表就可以了


3
投票

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


2
投票

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


1
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.