[Rd] lattice/points and pch="c" inconsistencies

David James dj@research.bell-labs.com
Thu Dec 12 16:49:06 2002


Hi,

The current lattice/grid packages seem to position character 
plotting symbols (e.g., ".") differently than the base function 
points.  The following shows what I mean:

## plain old points() positions the pch="." right at y = c(0,1),
## and thus abline(h = c(0,1)) completely hides the points "."
## (provided the output device has enough resolution, like postscript)

y <- rep(0:1, 50)
x <- 1:100

plot(x, y, pch = ".", cex = 2)
abline(h = c(0, 1))

## on the other hand, lattice/grid position the "." off the
## the y=0,1 lines, apparently centering the character's bounding box
## rather than the actual glyph;

xyplot(y~x, 
   panel = function(x, y, ...){
      panel.xyplot(x, y, ...)
      panel.abline(h = c(0, 1))
   },
   pch = ".", cex = 2
   )


I've noticed the argument "just=" in grid.text(), but its default
value of "centre" would seem to be what's needed in this example(?)

This behavior is consistent on Linux and Windows versions of R 1.6.1,
lattice 0.6-6, and grid 0.7-2.

Is this a lattice/grid feature or a bug?

-- 
David A. James
Statistics Research, Room 2C-253            Phone:  (908) 582-3082       
Bell Labs, Lucent Technologies              Fax:    (908) 582-3340
Murray Hill, NJ 09794-0636