[R] Crop white border for PDF output

Marc Schwartz MSchwartz at mn.rr.com
Tue Nov 22 14:42:23 CET 2005


On Tue, 2005-11-22 at 10:48 +0100, Claus Atzenbeck wrote:
> On Tue, 22 Nov 2005, Florence Combes wrote:
> 
> > I had not exactly the same pb, but close enough to propose you to take a
> > look at the options "fin" and "fig" in the par() function.
> 
> Thanks for your answer. In the meanwhile I also found another solution.
> I produce diagrams as usual and use pdfcrop to crop them afterwards. It
> takes two steps, but that's also OK.
> 
> Claus


Without your code, it is hard to know exactly what you need to resolve
the problem or why your manipulation of the margins did not work as you
want, but I am guessing that the following might be helpful.

Here is a default PDF plot:

 pdf("PDF1.pdf", height = 4, width = 4)
 barplot(1:5)
 dev.off()

 
Here is the same plot, but with the margins reduced:

 pdf("PDF2.pdf", height = 4, width = 4)
 par(mar = c(1, 3, 1, 1))
 barplot(1:5)
 dev.off()


Here is a default 2 x 2 plot:

 pdf("PDF3.pdf", height = 4, width = 4)
 par(mfrow = c(2, 2))
 barplot(1:5)
 barplot(1:5)
 barplot(1:5)
 barplot(1:5)
 dev.off()


Here is the same with reduced margins:

 pdf("PDF4.pdf", height = 4, width = 4)
 par(mfrow = c(2, 2))
 par(mar = c(1, 3, 1, 1))
 barplot(1:5)
 barplot(1:5)
 barplot(1:5)
 barplot(1:5)
 dev.off()



HTH,

Marc Schwartz




More information about the R-help mailing list