3

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

user1981275
  • 13,002
  • 8
  • 72
  • 101
NewNameStat
  • 2,474
  • 1
  • 19
  • 26
  • 4
    Can you please give a reproducible example < http://tinyurl.com/reproducible-000 > ? (I will refrain from snarking about 3D perspective pie charts ...) – Ben Bolker May 16 '13 at 18:44
  • 1
    Got it. I'm new to the community and appreciate any constructive criticism in my posts. – NewNameStat May 16 '13 at 19:03
  • There is a nice summary here of Cleveland's empirical research that shows why pie charts are a poor choice: http://en.wikipedia.org/wiki/Pie_chart In brief, they are difficult to read accurately and quickly. For the problem with 3D, see Tufte on chartjunk, start here: http://en.wikipedia.org/wiki/Chartjunk – Ben May 16 '13 at 19:20
  • 1
    @BenBolker I think the vertical white space is here for a good reason; as the viewer moves towards a top perspective, the pies will appear closer to each other (try tilting your screen). @ NewNameStat Joke aside, please do read those comments on why one should avoid 3D pie charts (and such colors, for that matter). – baptiste May 16 '13 at 19:30
  • What is a better way to quickly plot percentages? A bar plot puts too much emphasis on the mode in my opinion. – NewNameStat May 17 '13 at 05:52

2 Answers2

4

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

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
user1981275
  • 13,002
  • 8
  • 72
  • 101
  • 1
    Using the `pty='m'` argument will also help to reduce the whitespace on the sides. I think it would be a little tricky to remove the whitespace at the bottom, however. – nograpes May 16 '13 at 19:35
0

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))}
Rafael Díaz
  • 2,134
  • 2
  • 16
  • 32