lattice graphics in a R widget

自闭症网瘾萝莉.ら 提交于 2019-12-11 05:38:10

问题


Using the gWidgets package I have made a R widget that shows a lattice graphic when the user click on a button. The function producing the graphic (fgraph() below) runs well outside the widget. However the graphic at the topleft corner does not appear in the widget. Here is a reproducible code:

library(lattice)

sims <- data.frame(
    y=rnorm(8), 
    A=factor(c(1,1,1,1,2,2,2,2)), 
    B=factor(c(1,1,2,2,1,1,2,2)),
    C=factor(c(1,2,1,2,1,2,1,2))
)

fgraph <- function(sims){
    plot(
    dotplot(y ~ A | B+C , data = sims, 
             ylab="Zeta (mV)",  
            panel = function(...){
                panel.abline(v=c(1,2), col = "grey", lty = 2)
                panel.grid(col = "grey", lty = 2, v=0)
                panel.xyplot(..., pch = 16, col="black")
            }
        )
    )
}

library(gWidgetsRGtk2)
options(guiToolkit = "RGtk2")

win <- gwindow("Simulation")
GROUP <- ggroup(cont=win)

graphwindow <- ggraphics(container = GROUP,
    expand = TRUE, ps = 11)

GoGroup <- ggroup(horizontal=FALSE, container = GROUP)
addSpring(GoGroup)
Simulates <- gbutton(text="Simulates", container = GoGroup, 
    handler = function(h, ...) {
        fgraph(sims)
    }
) 

来源:https://stackoverflow.com/questions/14281135/lattice-graphics-in-a-r-widget

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!