I don't know where you get your claims from. R graphics is handled
internally in inches, with a device-specific mapping to pixels/points
etc (which is documented for each device on its help page). This has
to be done carefully, as pixels may not be square.
What the meaning of pch=1:23 is in terms of coordinates is not
documented except via the sources. The source is function GESymbol in
file src/main/engine.c, so for example pch = 2 is
case 2: /* S triangle - point up */
xc = RADIUS * GSTR_0;
r = toDeviceHeight(TRC0 * xc, GE_INCHES, dd);
yc = toDeviceHeight(TRC2 * xc, GE_INCHES, dd);
xc = toDeviceWidth(TRC1 * xc, GE_INCHES, dd);
xx[0] = x; yy[0] = y+r;
xx[1] = x+xc; yy[1] = y-yc;
xx[2] = x-xc; yy[2] = y-yc;
gc->fill = R_TRANWHITE;
GEPolygon(3, xx, yy, gc, dd);
break;
which as you see is in inches, not mm as you asserted. The first line
sets xc to 0.375 inches for cex=1, for example.
You need to take the stroke width (as set by lty) into account when
assessing the visual size of symbols
On Mon, 25 May 2009, baptiste auguie wrote:
Dear all,
Having received no answer in r-help I'm trying r-devel (hoping this is not a
stupid question).
I don't understand the rationale behind the absolute sizes of the point
symbols, and I couldn't find it documented (I got lost in the C code
graphics.c and gave up).
You are expected to study the sources for yourself. That's part of
the price of R.
There is a manual, 'R Internals', that would have explained to you
that graphics.c is part of base graphics and hence not of grid
graphics.
The example below uses
Grid to check the size of the symbols against a square of 10mm x 10mm.
checkOneSymbol <- function(pch=0){
gTree(children=gList(
rectGrob(0.5, 0.5, width=unit(10, "mm"), height=unit(10,
"mm"),
gp=gpar(lty=2, fill=NA, col=alpha("black", 0.5))),
pointsGrob(0.5, 0.5, size=unit(10, "mm"),pch=pch,
gp=gpar(col=alpha("red", 0.5)))
))
}
all.symbols <- lapply(0:23, checkOneSymbol)
pdf("symbols.pdf", height=1.2/2.54, width=24.2/2.54)
vp <- viewport(width=0.5, height=0.5, name="main")
pushViewport(vp)
pushViewport(viewport(layout=grid.layout(1, 24,
widths=unit(10, "mm"),
heights=unit(10, "mm"),
just="center")))
for(ii in 0:23){
pushViewport(viewport(layout.pos.col=ii+1, layout.pos.row=1))
grid.draw(all.symbols[[ii+1]])
upViewport(1)
}
dev.off()
What dictates the size of each symbol? (in other words, why is pch=21
a circle of radius given in inches, while pch=2 is a triangle of base
length specified in mm and offset vertically?, etc.)
I'm trying to develop a new symbol for the ggplot2 package where the size is
to be accurately mapped onto the data either in linear size or area. I was
expecting a similar idea behind the choice of base symbols. Is this
documented?
Best regards,
baptiste
_____________________________
Baptiste AuguiƩ
School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK
Phone: +44 1392 264187
http://newton.ex.ac.uk/research/emag
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
--
Brian D. Ripley, rip...@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
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel