[R] ridiculous behaviour printing to eps: labels all messed up!

Peter Dalgaard p.dalgaard at biostat.ku.dk
Mon Jun 8 08:23:04 CEST 2009


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




More information about the R-help mailing list