R小部件中的点阵图形

时间:2013-01-11 15:20:13

标签: r lattice gwidgets

使用gWidgets包我创建了一个R小部件,当用户单击按钮时,它会显示一个点阵图形。 生成图形的函数(下面的fgraph())在小部件之外运行良好。但是,topleft角上的图形不会出现在窗口小部件中。 这是一个可重现的代码:

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)
    }
) 

enter image description here

0 个答案:

没有答案