ggraphics {gWidgets} | R Documentation |
If a toolkit provides a graphics device, such as the cairoDevice package does for GTK+ or qtutils for Qt, this constructor makes devices that can then be embedded in other widgets. The notebook interface is one such example.
ggraphics(width = dpi * 6, height = dpi * 6, dpi = 75, ps = 12, container = NULL, ..., toolkit = guiToolkit()) ggraphicsnotebook(width=dpi*6, height=dpi*6,dpi=75, container = NULL,..., toolkit = guiToolkit())
width |
width in pixels of device |
height |
height in pixels of device |
dpi |
scale factor for default width and height |
ps |
pointsize |
container |
Optional container to attach widget to |
... |
Passed to add method of container. |
toolkit |
Which GUI toolkit to use |
When multiple graphics devices are present, clicking in the window of one will make that the current device.
The visible<-
method makes the object the current device.
The svalue(obj, ..., value)
method will save the visible window
to the file in value
. In gWidgetsRGtk2, if the window has
another window clipping part of it, this clipping will be shown. This
"hack" is needed, as dev.copy
does not currently work for the
"cairo" graphic device. (In future versions, there will be support for
pdf files within cairo.)
The addhandlerclicked(obj, handler, action, ...)
method where handler has
first argument h
has the additional values h\$x
and
h\$y
where these are values
are returned using "usr" coordinates (see help("par")
). (This was
in NDC coordinates)
For gWidgetsRGtk2 and gWidgetsQt there is also rubber-band
selection implemented. The addHandlerChanged
method can be used
to call a handler when the selection is completed. The x
and
y
components of h
record the lower left and upper right
points of the rectange. See the example for how this can do something
similar to "brushing".
## Not run: 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 }) ## End(Not run)