Search code examples
rgwidgets

Can I embed cranvas interactive graphics into gWidgets (gWidgetsQt) in R


I would like to know if there is a way to embed a cranvas interactive plot within a gWidgets GUI when using R. cranvas requires qtpaint and qtbase so the toolkit would probably be gWidgetsQt.

I was told that PlotView is a qWidget and so it should be possible to add a new gWidget e.g., ginteractive that wraps a cranvas plot.

See this Google Groups thread. If you need more info just ask, I am not a maintainer of cranvas though.


Solution

  • It required a slight change to gWidgetsQt (on r-forge now), but is now straightforward using the add method of a ggroup object. Here I embed an example from the qtime man page:

    g <- ggroup(cont=gwindow())
    require(cranvas)
    data(nasa)
    nasa11 <- subset(nasa, Gridx == 1 & Gridy == 1)
    qnasa <- qdata(nasa11)
    selected(qnasa)[1] <- TRUE
    cobj <- qtime(qnasa, TimeIndx, ts)
    
    add(g, cobj)
    

    Please, if you find bugs in gWidgetsQt, share them my way. The package is still new.