Skip to content
Prev 29506 / 63424 Next

grobX for points?

Hi R-devel,

It seems that grobX and grobY (from the grid package) do not refer to
the bounding box of a grid.points object.

library(grid)
library(lattice)
xyplot(1:10 ~ 1:10)
downViewport("plot1.panel.1.1.vp")
grob <- grid.get("GRID.points", grep=TRUE)
convertX(grobWidth(grob), "cm")
# 10.3430190058480cm
# (correct, but:)
convertX(grobX(grob, "west"), "cm")
# 5.89552083333333cm
convertX(grobX(grob, "east"), "cm")
# 5.89552083333334cm

So grobX is returning the midpoint, rather than the bounding box. This
is surprising, given that ?grobX says "If the grob describes multiple
shapes, in most cases, the boundary value will correspond to the edge
of a bounding box around all of the shapes."
R version 2.7.1 (2008-06-23)
i386-pc-mingw32

locale:
LC_COLLATE=English_Australia.1252;LC_CTYPE=English_Australia.1252;LC_MONETARY=English_Australia.1252;LC_NUMERIC=C;LC_TIME=English_Australia.1252

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets
methods   base

other attached packages:
[1] playwith_0.9-10      cairoDevice_2.8      gWidgetsRGtk2_0.0-36
RGtk2_2.12.5-3       gWidgets_0.0-28
[6] lattice_0.17-10

loaded via a namespace (and not attached):
[1] gridBase_0.4-3 tools_2.7.1