提问人:user2234497 提问时间:5/31/2013 最后编辑:user2234497 更新时间:12/10/2013 访问量:565
R gWidgets 包:在 ggraphis 区域中更新 ggplot 图表时停止白屏闪烁
R gWidgets package: stop white screen flashing upon updating a ggplot chart in a ggraphis area
问:
如何省略在 R 包的 ggraphis 区域中更改或更新图表时闪烁的白屏?ggplot2
gWidgets
当我使用 R 包中的 R 图时,在更新图表/绘图期间不会出现白屏。base
### 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)
-
答:
1赞
ferg
12/10/2013
#1
尝试更改 印刷(SPC) 自 打印(SPC,newpage=F)
评论