在R Plots中填充空白区域

时间:2013-05-16 18:40:57

标签: r plot space margins par

如下例所示,在R中绘图时如何摆脱空格?

enter image description here

我想这样做,因为当我想在页面上显示多个图时,它看起来很糟糕。

我正在以下列方式使用par函数:

par(mfrow=c(5,3),mai=rep(0,4), omi=rep(0,4))
pie3D(c(4,2,2,3,6,3),main="example")
pie3D(c(4,2,2,3,6,3),main="example")
...
pie3D(c(4,2,2,3,6,3),main="example") #do this 15 times. In my real work, it's 15 different pie charts.

给出了:

enter image description here

2 个答案:

答案 0 :(得分:3)

问题在于pie3D会将您的边距覆盖为c(4,4,4,4)

您可以在?pie3D中设置边距:

library("plotrix")
par(mfrow=c(5,3))
for (i in 1:15) pie3D(c(4,2,2,3,6,3),main="example", mar=c(0,0,1,0))

enter image description here

答案 1 :(得分:0)

补充前一位朋友的回复可以改变半径的饼图大小并减少空白区域。

library("plotrix")
par(mfrow=c(5,3))
for (i in 1:15){pie3D(c(4,2,2,3,6,3),radius = 2,main="example", mar=c(0,0,1,0))}