I've been testing plotmath. But I'm getting some funny output one one computer. The problem is that characters are 'jumbled' and overstrike when symbols are introduced. Sample code: mu <- 440.0 sigma <- 12.5 myx <- seq( mu - 4*sigma, mu+ 4*sigma, length.out=500) myDensity <- dnorm(myx,mean=mu,sd=sigma) # Here's one way to retrieve the values of mu and sigma and insert them into an expression t1t2 <- bquote (paste("Normal(", mu== .(mu), ',', sigma== .(sigma),")") ) plot(myx, myDensity, type="l", xlab="X", ylab="Probability Density ", main=t1t2) I have tested this code and it works on two desktop Fedora Linux 8 systems to make a nice figure, but on a Dell Laptop with Fedora Linux 8 and R 2.6.2, something funny happens: the characters "overstrike" each other. The Greek letter "mu" is printed several spaces to the left of the "(" that it is supposed to follow. I made an itty bitty picture of the figure title to show you: http://pj.freefaculty.org/R/plotmath_problem.png I can force in spaces to re-arrange the symbols so they do not overstrike. The following looks fine in the output. t1t2 <- bquote (paste("Normal ( ", mu== .(mu), ' , ', sigma=.(sigma)," )") ) ### Note spaces manually inserted above are needed, otherwise plotmath overlaps "l" of plot(myx, myDensity, type="l", xlab="X", ylab="Probability Density ", main=t1t2) What do you suppose is wrong? The X configuration? -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas
Peter Dalgaard
2008-Apr-08 09:09 UTC
[R] plotmath "overstrikes" in output on a Linux system
Paul Johnson wrote:> I've been testing plotmath. But I'm getting some funny output one one > computer. The problem is that characters are 'jumbled' and overstrike > when symbols are introduced. > > Sample code: > > mu <- 440.0 > sigma <- 12.5 > myx <- seq( mu - 4*sigma, mu+ 4*sigma, length.out=500) > myDensity <- dnorm(myx,mean=mu,sd=sigma) > > # Here's one way to retrieve the values of mu and sigma and insert > them into an expression > t1t2 <- bquote (paste("Normal(", mu== .(mu), ',', sigma== .(sigma),")") ) > > plot(myx, myDensity, type="l", xlab="X", ylab="Probability Density ", main=t1t2) > > > I have tested this code and it works on two desktop Fedora Linux 8 > systems to make a nice figure, but on a Dell Laptop with Fedora Linux > 8 and R 2.6.2, something funny happens: the characters "overstrike" > each other. The Greek letter "mu" is printed several spaces to the > left of the "(" that it is supposed to follow. I made an itty bitty > picture of the figure title to show you: > > http://pj.freefaculty.org/R/plotmath_problem.png > > I can force in spaces to re-arrange the symbols so they do not > overstrike. The following looks fine in the output. > > > t1t2 <- bquote (paste("Normal ( ", mu== .(mu), ' , ', sigma=> .(sigma)," )") ) > ### Note spaces manually inserted above are needed, otherwise plotmath > overlaps "l" of > > plot(myx, myDensity, type="l", xlab="X", ylab="Probability Density ", main=t1t2) > > > What do you suppose is wrong? The X configurationMy guess would be that something is wrong with the font metrics on one system. If the length of "Normal(" is miscalculated, that would explain the rest. Do you see the same thing if you do something like plot(0, main=quote(paste("Lengthy string", "A"))) It could be related to dpi settings; I seem to recall that this can do weird things on wide-screen displays. Doex xdpyinfo provide any clues? Look for lines like this screen #0: dimensions: 1024x768 pixels (260x195 millimeters) resolution: 100x100 dots per inch You could also play with the pointsize argument to X11() and see if the problem disappears at different sizes. -- 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
Prof Brian Ripley
2008-Apr-08 09:29 UTC
[R] plotmath "overstrikes" in output on a Linux system
Looks likes the the laptop is using different fonts with incorrect font metrics. This could happen because it has a different screen resolution, or one of the systems is set to use scalable fonts or it is giving metrics for one fonts and using another or .... BTW, this is probably nothing to do with plotmath per se -- the issue is most likely the device (presumably X11(), but you did not say) and its handling of font metric requests. It looks to me as if the widths of normal text strings (and not symbols) is the problem. I have seen something similar where there was a long-standing bug in plotmath (fixed in r44534), but this only manifested itself when text was kerned, which the X11() device in 2.6.2 does not ask for. My best guess is that the font selected is (to use the technical terms) returning glyph widths without left/right bearings. Please try 2.7.0 beta, which has a different X11() device (and the above bug fixed). That ought to solve the problem for you, but otherwise you'll need to debug what the X11 metricInfo callback is giving you. On Tue, 8 Apr 2008, Paul Johnson wrote:> I've been testing plotmath. But I'm getting some funny output one one > computer. The problem is that characters are 'jumbled' and overstrike > when symbols are introduced. > > Sample code: > > mu <- 440.0 > sigma <- 12.5 > myx <- seq( mu - 4*sigma, mu+ 4*sigma, length.out=500) > myDensity <- dnorm(myx,mean=mu,sd=sigma) > > # Here's one way to retrieve the values of mu and sigma and insert > them into an expression > t1t2 <- bquote (paste("Normal(", mu== .(mu), ',', sigma== .(sigma),")") ) > > plot(myx, myDensity, type="l", xlab="X", ylab="Probability Density ", main=t1t2) > > > I have tested this code and it works on two desktop Fedora Linux 8 > systems to make a nice figure, but on a Dell Laptop with Fedora Linux > 8 and R 2.6.2, something funny happens: the characters "overstrike" > each other. The Greek letter "mu" is printed several spaces to the > left of the "(" that it is supposed to follow. I made an itty bitty > picture of the figure title to show you: > > http://pj.freefaculty.org/R/plotmath_problem.png > > I can force in spaces to re-arrange the symbols so they do not > overstrike. The following looks fine in the output. > > > t1t2 <- bquote (paste("Normal ( ", mu== .(mu), ' , ', sigma=> .(sigma)," )") ) > ### Note spaces manually inserted above are needed, otherwise plotmath > overlaps "l" of > > plot(myx, myDensity, type="l", xlab="X", ylab="Probability Density ", main=t1t2) > > > What do you suppose is wrong? The X configuration? > > > -- > Paul E. Johnson > Professor, Political Science > 1541 Lilac Lane, Room 504 > University of Kansas-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595