Marius Hofert
2009-Oct-24 20:09 UTC
[R] dev.copy(postscript,...) generates a disrupted string
Dear R-Users, I have the following problem: I would like to create a postscript file containing an r-plot with the string "\\vartheta" in it (reason: this is later converted to the TeX-string "\vartheta" and a vartheta is printed in the figure). In the minimal example below, the problem is that the created postscript file does _not_ contain the string "\\vartheta " as a whole, but rather the following code: ... 284.38 36.00 (\\v) 0 ta -0.300 (ar) tb 0.480 (theta) tb gr ... The problem is, that the program which converts the created .ps file to a .tex file does not understand this disrupted string. Why does the dev.copy(postscript,..)-command produce such an output and how can I prevent it from doing so? If I use a different string such as "\\v_i", then everything works fine and "\\v_i" appears as a whole string in the postscript file. So why does it not work for "\\vartheta"? Thanks in advance, Marius ====Code========================================================= remove(list=objects()) library(lattice) x=c(1,2,3) y=c(1,4,9) xyplot(y~x,xlab=list("\\vartheta")) dev.copy(postscript,color=F,horizontal=F,onefile=F,file="myfile.ps") dev.off()
Barry Rowlingson
2009-Oct-24 20:28 UTC
[R] dev.copy(postscript,...) generates a disrupted string
On Sat, Oct 24, 2009 at 9:09 PM, Marius Hofert <m_hofert at web.de> wrote:> Dear R-Users, > > I have the following problem: I would like to create a postscript file > containing an r-plot with the string "\\vartheta" in it (reason: this is > later converted to the TeX-string "\vartheta" and a vartheta is printed in > the figure). In the minimal example below, the problem is that the created > postscript file does _not_ contain the string "\\vartheta" as a whole, but > rather the following code: > ... > 284.38 36.00 (\\v) 0 ta > -0.300 (ar) tb > 0.480 (theta) tb gr > ... > The problem is, that the program which converts the created .ps file to a > .tex file does not understand this disrupted string. Why does the > dev.copy(postscript,..)-command produce such an output and how can I prevent > it from doing so? If I use a different string such as "\\v_i", then > everything works fine and "\\v_i" appears as a whole string in the > postscript file. So why does it not work for "\\vartheta"?Because postscript() doesn't know what you want to do with \vartheta, and thinks you want to typeset the text itself. So it very cleverly adjusts the spacing between the letters to look nice - this is called 'kerning'. This means the text has to be set by postscript in several parts. You can do greek characters in plots - see help(plotmath). Barry