Search code examples
rpie-chartmargins

Remove excess whitespace in R pie charts?


Is there any way to reduce the amount of whitespace around pie charts generated using the base plotting tools in R?

I'd like to create a multi-panel figure but I can't figure out a way to reduce the amount of whitespace around the plot.

Example code:

par(mfrow=c(2,1))
pie(1:5)
pie(rep(1,5))

I tried playing with mar, omi, and oma within par(), but all values for those vectors seem to already be set to zero, and negative values are not accepted. Any way around this?


Solution

  • Graphical Parameters about the margin size of plots:

    • mai: the margin size in inches
    • mar: the margin size in lines of text
    • omi: the size of the outer margins in inches
    • oma: the size of the outer margins in lines of text

    All above are specified with a numerical vector of the form c(bottom, left, top, right).


    The default value of mai is :

    > par("mai")
    [1] 1.02 0.82 0.82 0.42
    

    You can reset it as:

    > par(mfrow = c(2, 1), mai = c(0, 0, 0, 0))