[Rd] plotmath under windows (PR#3672)
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Aug 7 09:42:50 MEST 2003
If it occurs on plotmath it will also occur on screen (and it does for
me on WinXP).
Why do you think this is a bug? IT IS intentional. Please don't waste
our time reporting things you don't understand as bugs -- see the FAQ and
ask for help on R-help/R-devel first. In particular, your claim is false
(it is only including characters which have descenders that has the
effect, and more careful chacking might have made you realise this was a
feature).
If you plot different labels they will have different heights and depths
(and different heights/depths under different fonts), and that is taken
into account. It often is not clear where the baseline on a plotmath
expression is, and it is taken as the bottom of the bounding box, whereas
for character vectors the baselines are the baselines of the strings.
The Windows and postscript font metrics are not the same, and it may well
be the case (and Uwe Ligges' report suggests so) that Windows font metrics
differ by version of Windows, something I think we have met before.
The exact cause here is that many of your plotmath expressions contain a
space, and in WinXP, a space extends below as well as above the line. So
paste(40 * degree, " ",30 * minute) has space at the bottom of its
bounding box, and 40 does not. It is precisely the plotmath expressions
containing spaces which are raised.
If you would like to change the behaviour, please submit a patch (against
the current R-devel code) for us to test.
Here is a small example of alignment for you to ponder
plot(1:10, type="n")
text(1:2, 2, c("i", "j"), adj=c(0.5, 0))
text(3:4, 2, expression("i", "j"), adj=c(0.5, 0))
abline(h=2)
Try it under postscript() as well. So your patch will need to establish
the correct baseline for plotmath expressions. We look forward to your
positive contributions to R.
On Thu, 7 Aug 2003 mh.smith at niwa.co.nz wrote:
> Full_Name: Murray H Smith
> Version: 1.7.1
> OS: Windows2000
> Submission from: (NULL) (202.36.29.1)
>
>
> This alleged bug is Windows specific and occurs when using Windows metafile
> plots.
> The problem does not occur in a Linux version.
> It does not occur in the pt rintout when a graphic is saved to a postscript file
> under Windows.
>
> The problem came to light when using plotmath to label a plot with latitudes
> containing degree symbols.
>
> If expression(40 * degree) is used it is written on the default line for
> labels.
>
> If expression(paste(40 * degree, " S") is used it displced closer to the axis.
> Pasting any character (except "") has this effect.
Not true. expression(paste(40 * degree, "S")) is not displaced here.
> The following code illustrates the problem.
>
> par(mfrow =c(3,2))
>
> # plotmath not used
> plot(seq(-41, -40, 0.5), c(0, 1, 0), type = "n", xlab = "latitude", ylab = "",
> xaxt = "n", yaxt = "n")
> axis(1, at = seq(-41, -40, 0.5),
> labels = seq(41 , 40, -0.5))
>
> # plotmath not used but characters pasted into labels
> plot(seq(-41, -40, 0.5), c(0, 1, 0), type = "n", xlab = "latitude", ylab = "",
> xaxt = "n", yaxt = "n")
> axis(1, at = seq(-41, -40, 0.5),
> labels = paste(seq(41, 40, -0.5), "S"))
>
> # last label has no character component
> plot(seq(-41, -40, 0.5), c(0, 1, 0), type = "n", xlab = "latitude", ylab = "",
> xaxt = "n", yaxt = "n")
> axis(1, at = seq(-41, -40, 0.5),
> labels = expression(paste(41 * degree, " S"), paste(40 * degree, " ", 30 *
> minute), 40 * degree))
>
> # last label has no plotmath component
> plot(seq(-41, -40, 0.5), c(0, 1, 0), type = "n", xlab = "latitude", ylab = "",
> xaxt = "n", yaxt = "n")
> axis(1, at = seq(-41, -40, 0.5),
> labels = expression(paste(41 * degree, " S"), paste(40 * degree, " ", 30 *
> minute), 40))
>
> # last label has null character component
> plot(seq(-41, -40, 0.5), c(0, 1, 0), type = "n", xlab = "latitude", ylab = "",
> xaxt = "n", yaxt = "n")
> axis(1, at = seq(-41, -40, 0.5),
> labels = expression(paste(41 * degree, " S"), paste(40 * degree, " ", 30 *
> minute), paste(40 * degree, "")))
>
> # last label has spaces character component
> plot(seq(-41, -40, 0.5), c(0, 1, 0), type = "n", xlab = "latitude", ylab = "",
> xaxt = "n", yaxt = "n")
> axis(1, at = seq(-41, -40, 0.5),
> labels = expression(paste(41 * degree, " S"), paste(40 * degree, " ", 30 *
> minute), paste(" ", 40 * degree, " ")))
>
> par(mfrow =c(1,1))
>
> ______________________________________________
> R-devel at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel
>
--
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
More information about the R-devel
mailing list