[R] Finding absolute viewport location in grid / lattice

Paul Murrell paul at stat.auckland.ac.nz
Fri Nov 8 01:51:18 CET 2013


Hi

Take a look at current.transform() (the grid.locator() function shows an 
example use)

Paul

On 11/06/13 13:35, James Price wrote:
> I'm trying to do some post-plot manipulation of some lattice
> graphics, in which I need to get the absolute viewport locations on
> the plotting device. So for example:
>
> library(lattice) print(xyplot(Petal.Length ~ Sepal.Length | Species,
> iris, layout = c(2, 2))) trellis.focus('panel', 1, 1)
>
> This shows the item I want to identify. I need to know, for example,
> that the lower left corner of the highlighted panel is at (0.1, 0.1)
> of the plotting device. Hopefully there's some grid shenanigans I can
> use to do so.
>
> To put the question into context (in case there's an alternative
> way): I'm constructing PDF reports that are an amalgam of PDF
> figures, constructed through LaTeX programmatically constructed in R,
> and I'd like to be able to add tooltips to some of the data points on
> the graphs. To do so, I'm overlaying a tikz (empty) image that uses
> the pdfcomment package to add the tooltips. Hence I need to be able
> to calculate where some of the points are on the screen so I can
> calculate where to put the tooltip 'hit-zones'. This would be fairly
> trivial using javascript / actionscript and mouseover hooks, but I'm
> constrained by PDF.
>
> Thanks, Jim Price. Strength in Numbers.
>
>  [[alternative HTML version deleted]]
>
> ______________________________________________ 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.
>

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/



More information about the R-help mailing list