[R] npc to native coordinates for xyplot

Jason Pare jay.pare at gmail.com
Mon Sep 1 18:22:18 CEST 2008


Hello,

I am having trouble adding symbols to grid graphics. I am able to
create a lattice scatterplot using xyplot, which has a range from
-15:15 in both the X and Y directions. However, when I try to add
circles and text to this graph using grid.circle() and grid.text(),
they are offset using the default npc coordinates.

Nothing happens when I pass the parameter default.units="native" to
grid.circle, as suggested in this
post:http://tolstoy.newcastle.edu.au/R/e4/help/08/03/5534.html. I also
tried replicating the code in Paul Murrell's GridBase documentation,
but to no avail:

xyplot(y ~ x, groups=pt, data=dt)
vps <- baseViewports()
pushViewport(vps$inner, vps$figure, vps$plot)
grid.circle(x=unit(-6,"native"), y=unit(-8,"native"), r=1)
popViewport(3)

Is there some other parameter or command that will convert the
grid.circle() NPC coordinates to the native coordinates within my
xyplot graph, and not the absolute dimensions of the viewport? I am
new to creating viewports and grid graphics in general, so any help
would be much appreciated.

Thanks,

Jason



More information about the R-help mailing list