[R] pdf with an exact size

Alberto Monteiro albmont at centroin.com.br
Fri Feb 23 19:24:54 CET 2007


Is it possible to create a pdf output file with an (as nearly as
possible) exact size?

For example, if I want to draw in an A4 paper (210 x 297 mm) a
square of 100 x 100 mm, how can I do it?

FWIW, about 6 months ago I learned here how to create an exact
png image. For example, if I want a 500 x 500 black square in 
a 1000 x 1000 white png, occupying the center of the png, the 
procedure is this:

  png("image.png", width=1000, height=1000, bg="white")
  par(mar=c(0,0,0,0)) # reset margins
  plot(0, xlim=c(0, 999), ylim=c(0, 999), col="white")
  par(usr=c(0, 999, 0, 999))
  points(c(250, 250, 749, 749, 250), c(250, 749, 749, 250, 250), 
    type="l", col="black")
  dev.off()

However, I don't know how do this with a pdf monstr... oops... file.

Alberto Monteiro



More information about the R-help mailing list