Re: [R] plotmath "overstrikes" in output on a Linux system

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Tue, 08 Apr 2008 11:09:21 +0200

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
My 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

______________________________________________
R-help_at_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.
Received on Tue 08 Apr 2008 - 09:11:49 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 08 Apr 2008 - 10:30:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive