On 9/1/08, Jason Pare <[EMAIL PROTECTED]> wrote: > 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.
I'm not sure why you are using baseViewports(); xyplot() uses grid, not base graphics. lattice provides means to access (most of) the viewports it creates. You could do: xyplot(y ~ x, groups=pt, data=dt) trellis.focus(highlight=FALSE) grid.circle(x=unit(-6,"native"), y=unit(-8,"native"), r=1) trellis.unfocus() There are other ways to do this too. -Deepayan ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.