rgtk2gwidgets

R low performance plotting with pch=16 in gWidgets2


On Windows I have recently updating R from 3.1.2 to 3.2.2 and updating all packages I am using as well (including cairoDevice). Now I observe that plotting under gWidgets2 shows a very poor performace, especially for pch=16,17,18:

library(gWidgets2,gWidgets2RGtk2)
options(guiToolkit="RGtk2")
win <- gwindow("Plot a figure",expand=TRUE)
gg <- ggraphics(container=win,expand=TRUE)
a <- seq(0,100,0.1) 
for (b in 1:20){
  par(pch = b)
  plot(c(0,100),c(0,100))
  start_time <- Sys.time()
  points(a,a)
  end_time <- Sys.time()
  print(paste("pch =",b,"time to plot:",end_time-start_time))
}

which gives:

[1] "pch = 1 time to plot: 0.134000062942505"
[1] "pch = 2 time to plot: 0.0380001068115234"
[1] "pch = 3 time to plot: 0.0569999217987061"
[1] "pch = 4 time to plot: 0.0550000667572021"
[1] "pch = 5 time to plot: 0.0409998893737793"
[1] "pch = 6 time to plot: 0.0379998683929443"
[1] "pch = 7 time to plot: 0.0859999656677246"
[1] "pch = 8 time to plot: 0.10699987411499"
[1] "pch = 9 time to plot: 0.0929999351501465"
[1] "pch = 10 time to plot: 0.180000066757202"
[1] "pch = 11 time to plot: 0.0740001201629639"
[1] "pch = 12 time to plot: 0.0859999656677246"
[1] "pch = 13 time to plot: 0.184999942779541"
[1] "pch = 14 time to plot: 0.062999963760376"
[1] "pch = 15 time to plot: 0.871000051498413"
[1] "pch = 16 time to plot: 49.2030000686646"
[1] "pch = 17 time to plot: 17.3880000114441"
[1] "pch = 18 time to plot: 24.2620000839233"
[1] "pch = 19 time to plot: 0.174000024795532"
[1] "pch = 20 time to plot: 0.128999948501587"

Without gWidgets2 the numbers are well below 0.1 sec. This effect is reproducable. Collegues of mine do see the same.

It must have to do with packages which I updated. Because when I remove R 3.2.2 and install 3.1.2 I don't get back the performance I had before updating everything.

Any idea??


Solution

  • [This is edited. At first it reported no slow down with the first method.]

    This isn't really an answer, but a followup. This is strange. I have three ways to do this. The first bypasses gwidgets2:

    win <- gtkWindow() gg <- gtkDrawingAreaNew() ps = 12 cairoDevice::asCairoDevice(gg, pointsize=ps) win$add(gg)

    This second one is a hybrid bypassing ggraphics:

    win <- gwindow() gg <- gtkDrawingAreaNew() ps <- 12 cairoDevice::asCairoDevice(gg, pointsize=ps) add(win, gg)

    (a hybrid of gWidgets2 and cairoDevice)

    and your original

    win <- gwindow() gg <- ggraphics(cont=win)

    At first I reported the first approach worked as expected, but not the latter 2. Now I see the opposite. The latter two are performing a bit better, but all perform poorly on pch=16, 17 or 18.

    I think your comment about the cairoDevice package is likely apt. I tested the above using the Gtk that installed when prompted after loading RGtk2. I'm not sure how to proceed. There are other reported issues with the ggraphics device under windows all with me punting to a similar answer. Hopefully this one isn't fatal to your plans.

    (I opened an issue at GitHub: https://github.com/jverzani/gWidgets2RGtk2/issues/15 to continue the discussion, as this isn't right for stackoverflow.)