2

How can I omit the white screen which flashes upon the change or update of a ggplot2 chart in a ggraphis area in the R gWidgets package?

When i utilize R plots from the base package of R, the white screen does not appear during the update of charts/plots.

### datos
library(cairoDevice)
library(ggplot2)
library(gWidgets)
library(gWidgetsRGtk2)
library(animation)
require(RGtk2)

variable <-rnorm(100)
datetime <-1:100

data=data.frame(variable=variable,datetime=datetime)

options(guiToolkit = "RGtk2")
window <- gwindow ("My first GUI",parent=c(1,1))
group1   <- ggroup(cont = window, horizontal=F,label="Variable1")
option                   <- glayout(cont=group1,horizontal=T ,spacing=0)
option[1,1:6,expand=T]   <-gb<- gbutton("Variable1", cont = option)
font(gb)                 <-c(weight="ultra-bold",size=11)
option[1,1:6,expand=T]  <-g1<-ggraphics(cont = option)
oopt = ani.options(interval = 1,loop =TRUE)
n=dim(data)[1]
for(i in 1:n){
  dev.hold()
  data2=data[which(data$datetime>=(i) & data$datetime<=(i+10)),]
  SPC <- ggplot(data2,aes(x=datetime,y=variable,group=1))+
    geom_line(size=1)+geom_point(size=3)+ 
    geom_line(aes(y=mean(variable),x=datetime[1:length(datetime)]),size=1,colour="green")+
geom_line(aes(y=mean(variable)+((3*sd(variable))/sqrt(length(variable))),x=datetime[1:length(datetime)]),size=1,colour="red")+
geom_line(aes(y=mean(variable)-((3*sd(variable))/sqrt(length(variable))),x=datetime[1:length(datetime)]),size=1,colour="red")+
scale_x_continuous(limits=c(i,i+10),breaks=c(seq(i,i+10,1)))+
theme_bw(base_size=12,base_family="")  
  print(SPC)

  ani.pause()
}
ani.options(oopt)

-
  • Welcome to Stackoverflow! I'm a bit confused by your question but tried to clean it up a bit nonetheless. If any of my edits changed the meaning, please re-edit your post. And what do you mean by 'white screen listed to the change'? If you could clarify that, that would probably enable an answer! – dlaehnemann May 30 '13 at 17:00
  • i am building a GUI with gWidgets package in R and i would want realize a "moving block" with the animation package with ggplot graphics, but this graphics are delayed in update to the other graphics and during update appears a white screen. This avoids having a motion effect and causes a flashing effect. i want to have a chart simmilar to a financial chart that is updated constantly in the time but i want to use ggplot graphs. – user2234497 May 30 '13 at 17:25
  • Thanks for this clarification. I think I understand your question now. However, I do not know the gWidgets package, so cannot provide you with much insight there. But you might want to also edit your question to include some sample data and some minimal code. There is some [good advice on how to do this in R](http://stackoverflow.com/a/5963610/2352071). – dlaehnemann May 30 '13 at 17:38

1 Answers1

1

Try changing print(SPC) to print(SPC,newpage=F)

ferg
  • 11
  • 1