Bryan Hanson
2008-Jul-21 01:03 UTC
[R] Lattice Version of grconvertX or variant on panel.text?
Still playing with Lattice... I want to use panel.text(x, y etc) but with x and y in plot coordinates (0,1), not user coordinates. I think if I had this problem with traditional graphics, I could use grconvertX to make the change. I did come across convertX {grid} but this doesn't seem to be what I need. Is there a function like grconvertX in Lattice, or is there a flag or some other method of making panel.text use plot coordinates? Thanks, Bryan
hadley wickham
2008-Jul-21 01:20 UTC
[R] Lattice Version of grconvertX or variant on panel.text?
On Sun, Jul 20, 2008 at 6:03 PM, Bryan Hanson <hanson at depauw.edu> wrote:> Still playing with Lattice... > > I want to use panel.text(x, y etc) but with x and y in plot coordinates > (0,1), not user coordinates. > > I think if I had this problem with traditional graphics, I could use > grconvertX to make the change. I did come across convertX {grid} but this > doesn't seem to be what I need.Looking at the code for panel.text (lattice:::ltext.default) it looks like the easiest way to go would be to call grid.text directly, specifying the units ("npc") that you want to use. Hadley -- http://had.co.nz/
Bryan Hanson
2008-Jul-21 01:24 UTC
[R] Lattice Version of grconvertX or variant on panel.text?
Never mind, I just hard-coded it using ratios. Simpler than I thought. Thanks, Bryan On 7/20/08 9:03 PM, "Bryan Hanson" <hanson at depauw.edu> wrote:> Still playing with Lattice... > > I want to use panel.text(x, y etc) but with x and y in plot coordinates > (0,1), not user coordinates. > > I think if I had this problem with traditional graphics, I could use > grconvertX to make the change. I did come across convertX {grid} but this > doesn't seem to be what I need. > > Is there a function like grconvertX in Lattice, or is there a flag or some > other method of making panel.text use plot coordinates? > > Thanks, Bryan > > ______________________________________________ > R-help at 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.
Gabor Grothendieck
2008-Jul-21 02:44 UTC
[R] Lattice Version of grconvertX or variant on panel.text?
Use grid.text instead: library(lattice) library(grid) xyplot(demand ~ Time, BOD, panel = function(...) { panel.xyplot(...) grid.text("Some text", .1, .1) # near lower left }) On Sun, Jul 20, 2008 at 9:03 PM, Bryan Hanson <hanson at depauw.edu> wrote:> Still playing with Lattice... > > I want to use panel.text(x, y etc) but with x and y in plot coordinates > (0,1), not user coordinates. > > I think if I had this problem with traditional graphics, I could use > grconvertX to make the change. I did come across convertX {grid} but this > doesn't seem to be what I need. > > Is there a function like grconvertX in Lattice, or is there a flag or some > other method of making panel.text use plot coordinates? > > Thanks, Bryan > > ______________________________________________ > R-help at 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. >