maiya
2009-Jun-08 00:00 UTC
[R] ridiculous behaviour printing to eps: labels all messed up!
OK, this is really weird! here's an example code: t1<-c(1,2,3,4) t2<-c(4,2,4,2) plot(t1~t2, xlab="exp1", ylab="exp2") dev.copy2eps(file="test.eps") that all seems fine... until you look at the eps file created, where for some weird reason, if you scroll down to the end, the code reads: /Font1 findfont 12 s 0 setgray 214.02 18.72 (e) 0 ta -0.360 (xp1) tb gr 12.96 206.44 (e) 90 ta -0.360 (xp2) tb gr Which means, that the labels "exp1" and "exp2" get split up!?!? Now visually that doesn't matter, but I use the labels to refer to them in LaTeX using psfrag, so I have to know exactly what they are called in the .eps file in order to reference them correctly. I've tried other labels and the splitting up seems completely random i.e doesn't have anything to do with the length of the label etc. I am completely lost here, can someone help me figure out what is going on here? Maja -- View this message in context: http://www.nabble.com/ridiculous-behaviour-printing-to-eps%3A-labels-all-messed-up%21-tp23916638p23916638.html Sent from the R help mailing list archive at Nabble.com.
Zeljko Vrba
2009-Jun-08 06:02 UTC
[R] ridiculous behaviour printing to eps: labels all messed up!
On Sun, Jun 07, 2009 at 05:00:18PM -0700, maiya wrote:> > I am completely lost here, can someone help me figure out what is going on > here? >With an unrelated problem, someone suggested to me never to use dev.copy2eps, but to open a new device with postscript() and draw the figure there. Maybe it will help with your problem too. Alternatively, as a (temporary) kludge, why don't you use one-letter names? Do you have more than 26 labels in the diagram?
Peter Dalgaard
2009-Jun-08 06:23 UTC
[R] ridiculous behaviour printing to eps: labels all messed up!
maiya wrote:> OK, this is really weird! > > here's an example code: > > t1<-c(1,2,3,4) > t2<-c(4,2,4,2) > plot(t1~t2, xlab="exp1", ylab="exp2") > dev.copy2eps(file="test.eps") > > that all seems fine... > > until you look at the eps file created, where for some weird reason, if you > scroll down to the end, the code reads: > > /Font1 findfont 12 s > 0 setgray > 214.02 18.72 (e) 0 ta > -0.360 (xp1) tb gr > 12.96 206.44 (e) 90 ta > -0.360 (xp2) tb gr > > Which means, that the labels "exp1" and "exp2" get split up!?!? > Now visually that doesn't matter, but I use the labels to refer to them in > LaTeX using psfrag, so I have to know exactly what they are called in the > .eps file in order to reference them correctly. > > I've tried other labels and the splitting up seems completely random i.e > doesn't have anything to do with the length of the label etc. > > I am completely lost here, can someone help me figure out what is going on > here? > > Maja >Look at the useKerning argument to postscript(). (AFAIR the rationale for the behaviour is that you cannot rely on having the output device do kerning while getting reliable string width calculations. I can't offhand recall the examples where it mattered, though.) -- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907