Skip to content

Buggy trellis.focus() with xyplot ?

6 messages · Daniel Kornhauser, Deepayan Sarkar, Felix Andrews

#
On Wed, Nov 19, 2008 at 8:55 AM, Daniel Kornhauser
<dkor at northwestern.edu> wrote:
It appears that the conversions used in the current implementation
(contributed by Felix Andrews) don't work when aspect != "fill"
(probably leading back to the use of 'respect = TRUE' in grid.layout).
The right way to do this is to first go down to the subregion
containing just the panels, and then locate the click location within
it. But this requires a suitable viewport to be predefined.

I have changed print.trellis to create such a dummy viewport
(accessible by trellis.focus("figure")), and modified trellis.focus()
to use it. I will test it a bit more before uploading a new version
(and also give Felix a chance to see if this breaks anything in
playwith etc.). To see if the fix works, you can try the svn copy at

https://svn.r-project.org/R-packages/trunk/lattice

-Deepayan
#
2008/11/20 Deepayan Sarkar <deepayan.sarkar at gmail.com>:
Yep, my fault, didn't think it through.
It won't affect playwith; playwith now uses a different approach: a function
inViewport(x.px, y.px, viewport)
reports whether a click location in pixels is inside the given
viewport. I loop through each panel viewport and check whether the
click is inside.

  
    
#
2008/11/20 Daniel Kornhauser <dkor at northwestern.edu>:
Yep, redrawing R plots is slow. If you remove a grob the whole plot
needs to be redrawn. The solution is to use highlight = FALSE in the
trellis.focus() command. Obviously then there will be no visual
indication (red outline) of which panel is in focus. (If you need that
you could draw it yourself and then overpaint it with white to hide
it, maybe... the best solution would be to draw it using Java
graphics, rather than R graphics, and store a buffer, but I don't know
whether that's possible in your system).
Sounds similar to some of the functionality of the 'playwith' and/or
'latticist' packages. You might want to look at them. playwith is
built with GTK+.

  
    
#
On 11/19/08, Daniel Kornhauser <dkor at northwestern.edu> wrote:
Call as trellis.unfocus(highlight=FALSE). Unhighlighting essentially
redraws the whole thing (this would be true whenever any component is
removed, though adding is fine).

-Deepayan