Hello everybody, I am wondering if it is possible to create a gui to plot a time series that is very big, it's an EEG signal of 20mins. What I would like to do is plot the first 5mins, then have a button on the gui that plots the next 5mins when pushed. Is it possible? Thanks in advance ! Gael.
Antonio, Fabio Di Narzo
2006-Mar-20 13:09 UTC
[R] create a gui with a button to change graphic?
See demos in the tcltk package. I remember there was some example of interactive graphics, with buttons to change graphical parameters. You can start from there... Antonio, Fabio Di Narzo. 2006/3/20, Gael de Lannoy <delannoy@dice.ucl.ac.be>:> > Hello everybody, > > I am wondering if it is possible to create a gui to plot a time series > that is very big, it's an EEG signal of 20mins. What I would like to do > is plot the first 5mins, then have a button on the gui that plots the > next 5mins when pushed. > > Is it possible? > > Thanks in advance ! > > Gael. > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > >[[alternative HTML version deleted]]
Adapt the function below to suit your needs. If you really want to
plot 5 minutes at a time, round the time series to the last MM:00
times (where MM is in 5*0:11) and have idx below loop over them.
splitplot <- function(x,points)
{
boundaries <- c(1,points*1:floor(length(x)/points),length(x))
for (i in 2:length(boundaries)) {
idx <- boundaries[i-1]:boundaries[i]
plot(idx,x[idx],type="o") #here you may prefer time.of.x[idx]
to idx
}
}
#examples
par(ask=TRUE) ; splitplot(rnorm(1000),350)
par(mfrow=c(3,1),ask=FALSE) ; splitplot(rnorm(1000),350)
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Gael de Lannoy
> Sent: Monday, March 20, 2006 7:40 AM
> To: r-help at stat.math.ethz.ch
> Subject: [R] create a gui with a button to change graphic?
>
> Hello everybody,
>
> I am wondering if it is possible to create a gui to plot a
> time series
> that is very big, it's an EEG signal of 20mins. What I would
> like to do
> is plot the first 5mins, then have a button on the gui that plots the
> next 5mins when pushed.
>
> Is it possible?
>
> Thanks in advance !
>
> Gael.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
Gael,
Try the following to get you started:
library(tkrplot)
y <- rnorm(10000, 10, 2) + 5*sin( (1:10000)/1000 )
tt <- tktoplevel()
left <- tclVar(1)
oldleft <- tclVar(1)
right <- tclVar(100)
f1 <- function(){
lleft <- as.numeric(tclvalue(left))
rright <- as.numeric(tclvalue(right))
x <- seq(lleft,rright,by=1)
plot(x,y[x], type='b',ylim=range(y))
}
img <- tkrplot(tt, f1)
f2 <- function(...){
ol <- as.numeric(tclvalue(oldleft))
tclvalue(oldleft) <- tclvalue(left)
r <- as.numeric(tclvalue(right))
tclvalue(right) <- as.character(r + as.numeric(...) - ol)
tkrreplot(img)
}
f3 <- function(...){
tkrreplot(img)
}
f4 <- function(...){
ol <- as.numeric(tclvalue(oldleft))
tclvalue(left) <- as.character(ol+100)
tclvalue(oldleft) <- as.character(ol+100)
r <- as.numeric(tclvalue(right))
tclvalue(right) <- as.character(r+100)
tkrreplot(img)
}
s1 <- tkscale(tt, command=f2, from=1, to=length(y),
variable=left, orient="horiz",label='left')
s2 <- tkscale(tt, command=f3, from=1, to=length(y),
variable=right, orient="horiz",label='right')
b1 <- tkbutton(tt, text='->', command=f4)
tkpack(img,s1,s2,b1)
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of
> Antonio, Fabio Di Narzo
> Sent: Monday, March 20, 2006 6:09 AM
> To: R-help at stat.math.ethz.ch
> Subject: [R] create a gui with a button to change graphic?
>
> See demos in the tcltk package. I remember there was some
> example of interactive graphics, with buttons to change
> graphical parameters. You can start from there...
>
> Antonio, Fabio Di Narzo.
>
> 2006/3/20, Gael de Lannoy <delannoy at dice.ucl.ac.be>:
> >
> > Hello everybody,
> >
> > I am wondering if it is possible to create a gui to plot a
> time series
> > that is very big, it's an EEG signal of 20mins. What I
> would like to
> > do is plot the first 5mins, then have a button on the gui
> that plots
> > the next 5mins when pushed.
> >
> > Is it possible?
> >
> > Thanks in advance !
> >
> > Gael.
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html
> >
> >
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>