3

I wonder if it's possible to slice a graph respectively a .png file generated with ggsave. If I do not want to use the default legend ort title and set it to FALSE it leaves me with a lot of white space. So is there an R way to just cut the file several pixels above and below the graph itself?

Thx in advance!

Matt Bannert
  • 27,631
  • 38
  • 141
  • 207

1 Answers1

7

You could change the plot.margin, e.g.

p + opts(plot.margin=unit(c(-1, 0, -1, 0), "lines"))

Since version 0.9.2 opts has been replaced by theme:

p + theme(plot.margin = unit(c(-1, 0, -1, -), "lines"))
joran
  • 169,992
  • 32
  • 429
  • 468
rcs
  • 67,191
  • 22
  • 172
  • 153
  • Thx, great idea! ggplot is so hilarious, all these options are really impressive. Though I can't really control my graph's bottom margin so far... (using "cm"). – Matt Bannert Aug 16 '10 at 09:32
  • does this margin work like css margin / padding definitions ? I was able to look up "unit" but could not figure out how top,bottom,left,right works in this case. – Matt Bannert Aug 16 '10 at 11:25