Hallo here is a simple proposal using tcltk-sliders.
Peter Wolf
# step 1: define general slider function
slider<-function(refresh.code,names,minima,maxima,resolutions,starts,title="control",no=0,
set.no.value=0){
# pw 03/2004
if(no!=0)
return(as.numeric(tclvalue(get(paste("slider",no,sep=""),env=slider.env))))
if(set.no.value[1]!=0){
try(eval(parse(text=paste("tclvalue(slider",set.no.value[1],")<-",
set.no.value[2],sep="")),env=slider.env));
return(set.no.value[2]) }
if(!exists("slider.env")) slider.env<<-new.env()
library(tcltk); nt<-tktoplevel(); tkwm.title(nt,title);
tkwm.geometry(nt,"+0+0")
for(i in seq(names))
eval(parse(text=paste("assign(\"slider",i,"\",tclVar(starts[i]),env=slider.env)",sep="")))
for(i in seq(names)){
tkpack(fr<-tkframe(nt)); lab<-tklabel(fr, text=names[i],
width="25")
sc<-tkscale(fr, command=refresh.code, from=minima[i], to=maxima[i],
showvalue=T, resolution=resolutions[i],
orient="horiz")
assign("sc",sc,env=slider.env);
tkpack(lab,sc,side="right")
eval(parse(text=paste("tkconfigure(sc,variable=slider",i,")",sep="")),env=slider.env)
}
tkpack(fr<-tkframe(nt),fill="x")
tkpack(tkbutton(fr, text="Exit",
command=function()tkdestroy(nt)),side="right")
tkpack(tkbutton(fr, text="Reset", command=function(){
for(i in seq(starts))
eval(parse(text=paste("tclvalue(slider",i,")<-",starts[i],sep="")),env=slider.env)
refresh.code() } ),side="left")
}
# step 2: define function for zooming
ts.zoom<-function(x,y,z){
# pw 05042004
library(tcltk)
n.ts<-1; if(!missing(y)) n.ts<-2; if(!missing(z)) n.ts<-3
refresh.code<-function(...){
# initialization
start<-slider(no=1)*100; delta<-slider(no=2)*100
if(start+delta>length(x))
start<-slider(set.no.value=c(1,(length(x)-delta)/100))*100
# plot
par(mfrow=c(n.ts,1))
plot(x,type="l",xlim=c(start,start+delta))
if(n.ts>=2) plot(y,type="l",xlim=c(start,start+delta))
if(n.ts>=3) plot(z,type="l",xlim=c(start,start+delta))
par(mfrow=c(1,1))
}
slider(refresh.code,
# names of sliders
c("begin index (unit=100)", "window width
(unit=100)"),
# min of sliders
c(0,1),
# max of sliders
c(floor(length(x)/100),length(x)/100),
# step of sliders
c(1,1),
# initial values
c(1,1))
}
# step 3: test it.
ts.zoom(runif(10000), rexp(10000), rnorm(10000))
Randy Zelick wrote:
>Hello list,
>
>Could the following be done without too much grief...?
>
>Lets say I have two or three time series objects that I want to inspect
>visually. Each I would plot with a y-offset so they stack up. They share
>the same X scaling. The problem is that each is perhaps 100K values. Due
>to the large number of values, features of the data sets cannot be seen
>when all values are plotted.
>
>What would be nice is to plot a fraction of the X range (say 10%). This
>would be equivalent to zooming in the X direction. Then using a key
>(ideally an arrow key), shift the viewing frame right or left to
>effectively scroll through the data. So first you view 0-10%, then 10-20%
>and so forth.
>
>If necessary I can fabricate a vector with X values in it and plot(x,y)
>instead of as time series, if this makes it any easier.
>
>I am using a Windows version of R.
>
>Thanks,
>
>=Randy>
>R. Zelick email: zelickr at pdx.edu
>Department of Biology voice: 503-725-3086
>Portland State University fax: 503-725-3888
>
>mailing:
>P.O. Box 751
>Portland, OR 97207
>
>shipping:
>1719 SW 10th Ave, Room 246
>Portland, OR 97201
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
>
>