If it is not the device then it's probably just the usage of an unexpected unit somewhere - as reported in another reply by another helper to your original question on R-help.

Best,
Uwe Ligges


willem vervoort wrote:
Hi Uwe,

I should send these messages from my member e-mail number

Thanks for that.
As you can see from the last bit of my code, I tried that, but it gave
the same results. I had a look at pdf.options() but didn't see
anything there either to make the text stay on the same spot. It seems
to also happen if you use png().


Willem



--------------------------------------------------------------------------------
From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de]
Sent: Fri 6/26/2009 6:47 PM
To: Willem Vervoort
Cc: r-help@r-project.org
Subject: Re: [R] panel.text and saving to pdf


To get reproducible results, I highly recommend to print the lattice
graphics directly into the desired device, i.e. start the pdf >(or jpeg
or whatever) device before printing.

Best,
Uwe Ligges



Willem Vervoort wrote:
Dear all,

I am not sure what I am doing wrong, but I have some unexplained behaviour when 
saving a lattice graph including text to a pdf file. The text seems to move 
around. It must have something to do with the way coordinates are set in 
devices other than jpg.

Any suggestions would be helpful
Willem

Here is some example code

setwd("c:/willem/research/misc")
today <- format(Sys.Date(),"%Y%m%d")


x <- runif(500)
y <- rnorm(500)

foo <- data.frame(x = x, y = y, z = rep(c("a","b"),250))
require(lattice)

xyplot(x~y|z,data=foo)
panel.text(370,470,"silly graph",cex=1.2,font=2)
savePlot(paste(today, "jpgplot",sep="_"),type="jpg") # this plots fine and text 
is as on the screen
savePlot(paste(today, "pdfplot",sep="_"),type="pdf") # text has moved

pdf(paste(today,"pdfplot2.pdf",sep="_")) # no difference using pdf
xyplot(x~y|z,data=foo)
panel.text(370,470,"silly graph",cex=1.2,font=2)
dev.off()

# There is also no difference

               _
platform       i386-pc-mingw32
arch           i386
os             mingw32
system         i386, mingw32
status
major          2
minor          9.0
year           2009
month          04
day            17
svn rev        48333
language       R
version.string R version 2.9.0 (2009-04-17)

-----------------------------------------------------------------
Dr. R.W. Vervoort
McCaughey Senior Lecturer Hydrology and Catchment Management
Faculty of Agriculture, Food and Natural Resources,
Bldg A04, The University of Sydney, NSW 2006
http://tinyurl.com/mccaughey
http://blogs.usyd.edu.au/waterhydrosu
ph: +61 2 9351 8744
fax: +61 2 9351 4953

______________________________________________
R-help@r-project.org 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-help@r-project.org 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.

Reply via email to