[R] Width of a plotting point (in inches) in grid package

Randall C Johnson [Contr.] rjohnson at ncifcrf.gov
Mon Feb 12 17:02:36 CET 2007


Hello,
I'm trying to determine the width of a plotting point (in inches) in the
grid package. I naively thought I could create a pointsGrob with only one
point and get the width (as tried below), but this results in an object with
a size of 0inches (changing cex has no effect). Does anyone have a better
approach? Of course, it would be dependent upon the graphics parameters and
viewport...

Thanks,
Randy

> library(grid)

> pushViewport(viewport())

> convertX(grobWidth(pointsGrob(1, 1)), 'inches')
[1] 0inches

# I think we're measuring the size of the point here...
# changing cex has no effect.
> convertX(grobWidth(pointsGrob(1, 1, gp = gpar(cex = 3))), 'inches')
[1] 0inches

# If I add a second point, the size should increase...
# how big is the plotting point though???
> convertX(grobWidth(pointsGrob(1:2, 1:2)), 'inches')
[1] 11.1929133858268inches

> sessionInfo()
R version 2.4.1 (2006-12-18)
i386-apple-darwin8.8.2

locale:
C

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


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Randall C Johnson
Bioinformatics Analyst
SAIC-Frederick, Inc (Contractor)
Laboratory of Genomic Diversity
NCI-Frederick, P.O. Box B
Bldg 560, Rm 11-85
Frederick, MD 21702
Phone: (301) 846-1304
Fax: (301) 846-1686
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



More information about the R-help mailing list