如何停止图形设备窗口切除plot()的边缘? [英] How to stop graphical device window cutting off edges of plot()?

查看:91
本文介绍了如何停止图形设备窗口切除plot()的边缘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个mfrow=c(6,4)图,还有一种特殊情况,我希望每个图都为mar=c(1,1,1,1).这样一来,底部4个图的x-axisxlab就会被砍掉(即使导出到.eps时也是如此).

I have a mfrow=c(6,4) plot and a special situation where I want each plot to be mar=c(1,1,1,1). This makes it such that the x-axis and the xlab of the bottom 4 graphs get chopped off (even when exporting to .eps).

如何停止R执行此操作?我试过做postscript("test.eps",height=N),其中N是比默认值大的一些实数.这会在.eps的顶部和底部留出很多空白,但x-axis仍被切除.

How do I stop R doing this? I've tried doing postscript("test.eps",height=N) where N is some real number that's larger than the default. This makes a lot of white space in the top and bottom of the .eps but the x-axis is still cut off.

所以我的问题是;考虑到我想要上述的mfrowmar的约束,我如何让plot()停止切断我的x-axisxlab? (我正在寻找某种方法来增大设备的底部,以使我想要的东西不会被砍掉?).

So my question is; how do I get plot() to stop cutting off my x-axis and xlab given the constraint that I want the mfrow and mar described above? (I'm looking perhaps for some way to make the bottom of the device bigger such that the stuff I want isn't chopped off?).

这是我的情节:

postscript("test.eps")
y <- rnorm(100)
x <- rnorm(100)

par(mfrow=c(6,4),mar=c(1,1,1,1))

for(i in 1:((6*4)))
{
    if(i <= (6*4)-4)
    {
    plot(y,x,xlab="",xaxt="n")
    }
    if(i > (6*4)-4)
    {
    plot(y,x,xlab="HELLO")
    }
}
dev.off()

推荐答案

我建议您添加外部页边距(oma)以不裁剪刻度线标签,并使用mtext绘制轴标签以使其更接近而不是默认位置.

I suggest you add an outer margin (oma) to not clip the tick labels, and plot the axis-label with mtext to get it closer than the default position.

postscript("test.eps")
y <- rnorm(100)
x <- rnorm(100)

par(mfrow=c(6,4),mar=c(1,1,1,1), oma=c(3,1,0,0))

for(i in 1:((6*4)))
{
    if(i <= (6*4)-4)
    {
    plot(y,x,xlab="",xaxt="n")
    }
    if(i > (6*4)-4)
    {
    plot(y,x,xlab="")
    mtext("HELLO", 1, 2.5)
    }
}
dev.off()

这篇关于如何停止图形设备窗口切除plot()的边缘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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