win <- gwindow("Graphics example")
ggraphics(ps=6, container=win)
hist(rnorm(100))
## This is for gWidgetsRGtk2 (along with cairoDevice) or qtutils
library(gWidgets)
options(guiToolkit="RGtk2") ## "Qt"
w <- gwindow("brush example", visible=FALSE)
g <- ggroup(cont=w)
tbl <- gtable(mtcars, cont=g, filter.FUN="manual")
size(tbl) <- c(300, 500)
gg <- ggraphics(cont=g)
visible(w) <- TRUE
makePlot <- function(ind) {
plot(mpg ~ wt, mtcars)
if(!missing(ind) && any(ind))
points(mpg ~ wt, mtcars[ind,], cex=2, pch=16, col="red")
}
ID <- addHandlerChanged(gg, handler=function(h,...) {
x <- h$x; y <- h$y
ind <- (mtcars$wt >= x[1]) & (mtcars$wt <= x[2]) &
(mtcars$mpg >= y[1]) & (mtcars$mpg <= y[2])
## udpate graphic and data frame
makePlot(ind)
if(any(ind))
visible(tbl) <- ind
})
Run the code above in your browser using DataLab