1

I am using gWidgets in R. I would like two plots to appear side by side after I split the screen. I cannot figure out why no data points appear in the second screen.

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

You should see that the second plot appears but it contains no data points. I am using 32-bit R 2.13.2 on a 32-bit Windows laptop. Any help with this is much appreciated. Thank you.

Anto
  • 449
  • 5
  • 14
  • I tried on my Linux machine with RGtk2 and, for your code, got the error message `Error in plot.new() : figure margins too large`. By trial and error I found that `ggraphics(dpi = 150, ps=6, container=win)` displays what I think you want. Not an answer really, but if it helps... – vaettchen Nov 27 '12 at 16:31
  • Cheers. That didn't do much for me unfortunately. Also, an update to my question. Use the line `options(guiToolkit = "RGtk2")` so you won't be prompted to select a GUI toolkit. – Anto Nov 27 '12 at 16:54

2 Answers2

1

Is is a problem of refresh ggraphics. I think it is better to put it in a ggroup.

For example you can do this:

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

agstudy
  • 119,832
  • 17
  • 199
  • 261
1

It may also be an issue with the window not allocating enough initial space to accommodate the graphic. To avoid this, try passing visible=FALSE to the gwindow constructor and after all the components are added show the window with visible(win) <- TRUE

jverzani
  • 5,600
  • 2
  • 21
  • 17
  • A useful check. Thank you but there are many other things going on here. I just took out a little snippet of code to demonstrate my problem. – Anto Nov 28 '12 at 17:31