2015-04-22 63 views
0

大家好我有3个密度条在任一轴上的密度条,我已经这样做了(这里是一个简单的形式,只有3个普通的情节,但其他部分是必要的需要本人已离开这里只是为了便于观察)标题在R中的剧情画布中的框架

 scatterBar.Norm <- function(x,y) { 
    zones <- matrix(c(2,0,1,3), ncol=2, byrow=TRUE) 
    layout(zones, widths=c(5/7,2/7), heights=c(2/7,5/7)) 
    title("My Title", outer=TRUE); 
    par(mar=c(3,3,1,1),mgp=c(2,1,0)) 
    plot(1:10, xlab="Magnification", ylab="residue", col=2) 
    par(mar=c(0,3,1,1)) 
    plot(1:10, xlab="Magnification", ylab="residue",col=3) 
    par(mar=c(3,0,1,1)) 
    plot(1:10, xlab="Magnification", ylab="residue", col=4)} 

    scatterBar.Norm(2,3) 

的问题更复杂的功能: 首先在情节标题“我的标题”部分走出去的画布,如何修理它 ?

感谢您提前所需的帮助。

+3

为什么你使用''上B' attach'和'e2'在同一时间?它们具有相同的变量名称。正因为这个原因,你应该避免使用'attach'。 – sebpardo

+0

没有示例数据,这个问题不是[reproducible](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)。如果我们不能自己重新创造情节,那么帮助并不容易。另外,请确保您发布*最少*可重现的示例。拿出任何不需要的代码来重现问题。少数几条线路越容易找到问题。 – MrFlick

+0

使用cex.main来减小字体大小或使用“\ n”将标题分成多行。并且_never_使用附加! –

回答

1

您已经指示R在外边缘绘制标题,但是(至少在您的示例中)您没有设置边距。下面应该工作:

scatterBar.Norm <- function(x, y) { 
    zones <- matrix(c(2, 0, 1, 3), ncol=2, byrow=TRUE) 
    layout(zones, widths=c(5, 2), heights=c(2, 5)) 
    par(mar=c(3, 3, 1, 1), mgp=c(2, 1, 0), oma=c(0, 0, 3, 0)) 
    plot(1:10, xlab="Magnification", ylab="residue", col=2) 
    par(mar=c(0, 3, 1, 1)) 
    plot(1:10, xlab="Magnification", ylab="residue", col=3) 
    par(mar=c(3, 0, 1, 1)) 
    plot(1:10, xlab="Magnification", ylab="residue", col=4) 
    title("My Title", outer=TRUE) 
} 

plot.new() 
scatterBar.Norm(2, 3) 

enter image description here