plot.new()中的错误:R中的图边距太大 [英] Error in plot.new() : figure margins too large in R

查看:949
本文介绍了plot.new()中的错误:R中的图边距太大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是R的新手,但是我使用较小的数据集绘制了许多相关图.但是,当我尝试绘制一个大型数据集(2gb +)时,我可以很好地生成该图,但是图例不会显示.有什么建议吗?或替代品?

I'm new to R but I've made numerous correlation plots with smaller data sets. However, when I try to plot a large dataset (2gb+), I can produce the plot just fine, but the legend doesn't show up. Any advice? or alternatives?

library(gplots)
r.cor <- cor(r)
layout(matrix(c(1,1,1,1,1,1,1,1,2,2), 5, 2, byrow = TRUE))
par(oma=c(5,7,1,1))
cx <- rev(colorpanel(25,"yellow","black","blue"))
leg <- seq(min(r.cor,na.rm=T),max(r.cor,na.rm=T),length=10)
image(r.cor,main="Correlation plot Normal/Tumor data",axes=F,col=cx)
axis(1, at=seq(0,1,length=ncol(r.cor)), labels=dimnames(r.cor)[[2]], 
    cex.axis=0.9,las=2)
axis(2,at=seq(0,1,length=ncol(r.cor)), labels=dimnames(r.cor)[[2]],
     cex.axis=0.9,las=2)
image(as.matrix(leg),col=cx,axes=T)     

plot.new()中的错误:图形边距太大

Error in plot.new() : figure margins too large

tmp <- round(leg,2)
axis(1,at=seq(0,1,length=length(leg)), labels=tmp,cex.axis=1)

推荐答案

我怀疑问题是您的layout()调用创建的小图形区域2不够大,不足以仅包含默认边距,更不用说情节.

I suspect the problem is that the small figure region 2 created by your layout() call is not sufficiently large enough to contain just the default margins, let alone a plot.

在引起问题的行之前尝试:

Before the line causing the problem try:

par(mar = rep(2, 4))

然后绘制第二张图片

image(as.matrix(leg),col=cx,axes=T)

您需要在我展示的par()调用中调整边距的大小,以正确解决此问题.您可能还需要增加要绘制的实际设备的大小.

You'll need to play around with the size of the margins on the par() call I show to get this right. You may also need to increase the size of the actual device onto which you are plotting.

最后一个提示,保存par()默认值,然后再进行更改,因此将现有的par()调用更改为:

A final tip, save the par() defaults before changing them, so change your existing par() call to:

op <- par(oma=c(5,7,1,1))

然后在绘图结束时完成

par(op)

这篇关于plot.new()中的错误:R中的图边距太大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆