【问题标题】:gWidgets: points are not appearing in second screengWidgets:点未出现在第二个屏幕中
【发布时间】:2012-11-27 14:38:14
【问题描述】:

我在 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。对此的任何帮助将不胜感激。谢谢。

【问题讨论】:

  • 我在我的 Linux 机器上尝试使用 RGtk2,对于您的代码,收到了错误消息 Error in plot.new() : figure margins too large。通过反复试验,我发现ggraphics(dpi = 150, ps=6, container=win) 显示了我认为您想要的内容。不是一个真正的答案,但如果它有帮助......
  • 干杯。不幸的是,这对我没有多大帮助。另外,我的问题的更新。使用 options(guiToolkit = "RGtk2") 行,这样就不会提示您选择 GUI 工具包。

标签: r gwidgets


【解决方案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))

})

【讨论】:

  • ggroup 可能是正确的答案,因为您的代码确实有效。谢谢!
  • 谢谢!这取决于您是要手动放置绘图还是将其委托给 ggroup。
【解决方案2】:

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

【讨论】:

  • 一个有用的检查。谢谢,但这里还有很多其他事情。我只是拿出了一点sn-p代码来演示我的问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多