سؤال

How does one get rid of white space when plotting in R as in the example below?

enter image description here

I would like to do this because when I want to multiple plots on a page it looks terrible.

I'm using the par function in the following way:

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.

Which gives:

enter image description here

هل كانت مفيدة؟

المحلول

The problem is that pie3D overwrites your margins to c(4,4,4,4).

You can set margins in ?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

نصائح أخرى

Complementing the response of the previous friend can change the size of the pie with radius and reduce the white space.

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))}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top