gWidgets:点不会出现在第二个屏幕中

时间:2012-11-27 14:38:14

标签: r gwidgets

我在R中使用gWidgets。我想在分割屏幕后并排显示两个图。我无法弄清楚为什么第二个屏幕上没有数据点出现。

library(gWidgets)
win <- gwindow("Graphics example")  # Create a window.
# You will be prompted to select a GUI toolkit.
# Enter "1" for gWidgetsRGtk2
ggraphics(ps=6, container=win)
split.screen(c(1,2))  # Split screen into 2 halves
screen(1)
plot(c(1:10), rnorm(10))
screen(2)
plot(c(1:10), rnorm(10))

您应该会看到第二个图表出现,但它不包含任何数据点。我在32位Windows笔记本电脑上使用32位R 2.13.2。对此有任何帮助非常感谢。谢谢。

2 个答案:

答案 0 :(得分:1)

是刷新ggraphics的问题。我认为最好把它放在 ggroup

例如,你可以这样做:

library(gWidgets)
options(guiToolkit="RGtk2") ## "Qt"
w <- gwindow("brush example", visible=FALSE)
g <- ggroup(container=w)
## I create 2 ggraphics , the container is ggroup
gg <- ggraphics(container=g)
gg1 <- ggraphics(container=g)
visible(w) <- TRUE
## Here we create 2 handlers to refresh the plot on the click
## See documentation of gWidgets for other handler
ID <- addHandlerChanged(gg, handler=function(h,...) {
  ## udpate graphic and data frame
  plot(c(1:10), rnorm(10))

})

ID1 <- addHandlerChanged(gg1, handler=function(h,...) {
  ## udpate graphic and data frame
  plot(c(1:10), rnorm(10))

})

enter image description here

答案 1 :(得分:1)

窗口没有分配足够的初始空间来容纳图形也可能是一个问题。为避免这种情况,请尝试将visible=FALSE传递给gwindow构造函数,并在添加完所有组件后显示带visible(win) <- TRUE的窗口

相关问题