Re: [R] pdf with an exact size

2007-02-24 Thread Renaud Lancelot
The package grid provides very convenient tools for such things:

library(grid)
pdf(file = square.pdf, paper = a4)
pushViewport(viewport())
grid.rect(width = 100, height = 100, default.units = mm)
dev.off()

works just fine for me (R 2.4.1, MS WIndows XP): the printed output on
my inkjet printer is exactly 100 mm x 100 mm.

Best,

Renaud

2007/2/23, Joerg van den Hoff [EMAIL PROTECTED]:
 On Fri, Feb 23, 2007 at 04:24:54PM -0200, Alberto Monteiro wrote:
  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
 

 going via `bitmap' and using the `pdfwrite' type is probably the better
 idea since in this case `ghostscript` is used for pdf generation which seems
 over all to generate cleaner/better pdf-output in comparsion
 to the R internal pdf-device (I believe there was recently some
 discussion of this on the list?).

 joerg

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



-- 
Renaud LANCELOT
Département Systèmes Biologiques du CIRAD
CIRAD, Biological Systems Department

Campus International de Baillarguet
TA 30 / B
F34398 Montpellier
Tel   +33 (0)4 67 59 37 17
Secr. +33 (0)4 67 59 37 37
Fax   +33 (0)4 67 59 37 95

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] pdf with an exact size

2007-02-23 Thread Alberto Monteiro
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

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] pdf with an exact size

2007-02-23 Thread Alberto Monteiro
I must be stupid and/or crazy... I figured out the solution a few
minutes after I asked :-/

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

Yes:

  pdf(a4.pdf, width=210, height=297, bg=white, paper=a4)
  par(mar=c(0,0,0,0)) # reset margins
  plot(0, xlim=c(0, 210), ylim=c(0, 297), col=white)
  par(usr=c(0, 210, 0, 297))
  points(c(100, 100, 200, 200, 100), c(100, 200, 200, 100, 100, 100),
type=l, col=black)
  dev.off()
 
Alberto Monteiro

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] pdf with an exact size

2007-02-23 Thread Joerg van den Hoff
On Fri, Feb 23, 2007 at 04:24:54PM -0200, Alberto Monteiro wrote:
 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
 

going via `bitmap' and using the `pdfwrite' type is probably the better
idea since in this case `ghostscript` is used for pdf generation which seems
over all to generate cleaner/better pdf-output in comparsion
to the R internal pdf-device (I believe there was recently some
discussion of this on the list?).

joerg

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.