Eric Stone
2012-Dec-11 18:59 UTC
[R] Focus on a sub-panel of a splom with trellis.focs() -- return coordinate of sub-panel, or names of variables therein
Hi, I'd like to be able to generate a splom plot in R and then use my mouse to click on one of the sub-panels (panel.pairs, specifically) and have R return either the coordinates of that sub-panel, or even better, the names of the corresponding variables plotted in that sub-panel. Here's an example to work with:> library(lattice) > splom(~iris[1:4], groups = Species, data = iris,+ panel = panel.superpose, + key = list(title = "Three Varieties of Iris", + columns = 3, + points = list(pch = super.sym$pch[1:3], + col = super.sym$col[1:3]), + text = list(c("Setosa", "Versicolor", "Virginica")))) This is what I've been able to come up with so far, but I know it's not what I need. I'd like to be able to select an entire sub-panel> trellis.focus() > panel.link.splom() #click on a point in the plot, then hit 'esc'[1] 80 111> trellis.unfocus() #to end trellis.focusThanks for your help, Eric [[alternative HTML version deleted]]
ilai
2012-Dec-11 20:05 UTC
[R] Focus on a sub-panel of a splom with trellis.focs() -- return coordinate of sub-panel, or names of variables therein
You could try require(grid) trellis.focus() names(iris)[round(unlist(grid.locator()))] trellis.unfocus() cheers On Tue, Dec 11, 2012 at 11:59 AM, Eric Stone <eric.stone@temple.edu> wrote:> Hi, > I'd like to be able to generate a splom plot in R and then use my mouse to > click on one of the sub-panels (panel.pairs, specifically) and have R > return either the coordinates of that sub-panel, or even better, the names > of the corresponding variables plotted in that sub-panel. > > Here's an example to work with: > > > library(lattice) > > splom(~iris[1:4], groups = Species, data = iris, > + panel = panel.superpose, > + key = list(title = "Three Varieties of Iris", > + columns = 3, > + points = list(pch = super.sym$pch[1:3], > + col = super.sym$col[1:3]), > + text = list(c("Setosa", "Versicolor", "Virginica")))) > > This is what I've been able to come up with so far, but I know it's not > what I need. I'd like to be able to select an entire sub-panel > > > trellis.focus() > > panel.link.splom() #click on a point in the plot, then hit 'esc' > > [1] 80 111 > > > trellis.unfocus() #to end trellis.focus > > Thanks for your help, > Eric > > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. >[[alternative HTML version deleted]]