我想将一个共同的传说集中在两个地块下面.我曾经xpd=TRUE允许在剧情本身之外进行打印,并且oma为图例创造空间.然而,传说不会在水平方向上移动并且会在"早期"垂直方向上被剪切.有什么建议?
quartz(title="PCoA",12,6)
par(mfrow=c(1,2),oma=c(5,0,0,0),xpd=TRUE)
plot(1:3,4:6,main="plot 1")
plot(1:3,4:6,main="plot 2")
# Clips the plot
legend(1,3.5,ncol=3,c("0-1 km","1-5 km","outside barrier"),fill=c("green","orange","red"), title="Fetch")
# Won't let me move the legend sideways
legend(0,3.5,ncol=3,c("0-1 km","1-5 km","outside barrier"),fill=c("green","orange","red"), title="Fetch")
Run Code Online (Sandbox Code Playgroud)

UPDATE
通过下面的解决方案,可以通过拖动边缘来改变图形的尺寸,从而切割图形的边缘(见下文).可能会发生什么想法?


And*_*rie 15
而不是使用par=mfrow(...)我建议你使用layout().
这允许您指定具有绘图位置的矩阵:
layout(matrix(c(1,2,3,3), ncol=2, byrow=TRUE), heights=c(4, 1))
par(mai=rep(0.5, 4))
plot(1:3,4:6,main="plot 1")
plot(1:3,4:6,main="plot 2")
par(mai=c(0,0,0,0))
plot.new()
legend(x="center", ncol=3,legend=c("0-1 km","1-5 km","outside barrier"),
fill=c("green","orange","red"), title="Fetch")
Run Code Online (Sandbox Code Playgroud)

par(xpd=NA)就是您要找的东西。从?par帮助页面中提取:
xpd
逻辑值或NA。如果为FALSE,则将所有绘图剪切到绘图区域;如果为TRUE,则将所有绘图剪切到图形区域;如果为NA,则将所有绘图剪切到设备区域。另请参阅clip。
实际上,您希望将其剪切到设备区域而不是图形区域(例如,请参见此博客条目,以图形方式说明图形,图形和设备区域之间的差异)。
quartz(title="PCoA",12,6)
par(mfrow=c(1,2),oma=c(5,0,0,0),xpd=NA)
plot(1:3,4:6,main="plot 1")
plot(1:3,4:6,main="plot 2")
legend(-0.5,3.5,ncol=3,c("0-1 km","1-5 km","outside barrier"),
fill=c("green","orange","red"), title="Fetch")
Run Code Online (Sandbox Code Playgroud)

| 归档时间: |
|
| 查看次数: |
20749 次 |
| 最近记录: |