[R] PDF file not created correctly

Uwe Ligges ligges at statistik.uni-dortmund.de
Fri Jul 5 18:18:27 CEST 2002



james.holtman at convergys.com wrote:
> 
> I am trying to put some text data in a graphical output file so that I have
> a single file with both the graphs and summary data.  I was capturing the
> output via a 'sink(textConnection('output','w')).  This seems to work fine,
> but in trying to put the text data in a graphics frame, I was having
> problems.  When creating a postscript file, things were fine, but a PDF
> file appeared not to be correct.
> 
> Here is a test file I created which appears to create the correct output
> for postscript and BMP, but not for PDF.
> 
> platform i386-pc-mingw32
> arch     i386
> os       mingw32
> system   i386, mingw32
> status
> major    1
> minor    5.1
> year     2002
> month    06
> day      17
> language R
> 
> #=============================================================
> x.buffer <- c('this is a test','next line') # create test data
> #
> # create a postscript file (OK)
> #
> postscript('test.ps')
> par(mfrow=c(1,1))
> plot.new()
> text(par('usr')[1],par('usr')[4],paste(x.buffer, collapse='\n'), font=1,
>     adj=c(0,1),cex=.8, col='red')
> dev.off()
> #
> # now try is as a PDF file (EMPTY)
> #
> pdf('test.pdf')
> par(mfrow=c(1,1))
> plot.new()
> text(par('usr')[1],par('usr')[4],paste(x.buffer, collapse='\n'), font=1,
>     adj=c(0,1),cex=.8, col='red')
> dev.off()
> #
> # now try BMP (OK)
> #
> bmp('test.bmp')
> par(mfrow=c(1,1))
> plot.new()
> text(par('usr')[1],par('usr')[4],paste(x.buffer, collapse='\n'), font=1,
>     adj=c(0,1),cex=.8, col='red')
> dev.off()




You need to set up the coordinate system with plot.window() after
plot.new(). For me it is a surprise that the non-pdf solutions work.

Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list