[R] interactive time series plot

Paul Murrell p.murrell at auckland.ac.nz
Mon Aug 29 22:34:57 CEST 2005


Hi

You might also want to check out getGraphicsEvent (on Windows)

Paul


Greg Snow wrote:
> I don't think that the par(ask=T) will do it for you.  Some alternatives
> to try:
> 
> 1. use the slider function in either the relax package or the
> TeachingDemos
>     package to create a Tk slider that you move back and forth with the
> mouse
>    and have the graph update accordingly.
> 
> 2. Use locator(1) to have the user advance the graph by clicking and
> have
>     your function determine the direction moved based on if they click
> on the
>     right or left part of the graph (see put.points.demo in
> TeachingDemos
>     package for an example).
> 
> 3. Use the readline function to prompt for keyboard input and move the
> 
>     window based on the keyboard input.
> 
> hope this helps,
> 
> Greg Snow, Ph.D.
> Statistical Data Center, LDS Hospital
> Intermountain Health Care
> greg.snow at ihc.com
> (801) 408-8111
> 
> 
>>>>"Chris Paulse" <cpaulse at aecom.yu.edu> 08/29/05 12:03PM >>>
>>>
> Hi,
> 
> I've written the following function to display small windows of a time
> series (and a processed version of it) with mouse clicks used to move
> the
> window forward.
> 
>  
> 
> ViewRawAndProcessed <- function(raw, processed, width=1000)
> 
> {
> 
>       len <- length(raw)
> 
>       n <- round(len/width)
> 
>       for (i in 1:n)
> 
>       {
> 
>             plot(raw[((i-1)*width):(i*width)], type="s")
> 
>             lines(processed[((i-1)*width):(i*width)], type="s",
> col="red")
> 
>             s <- sprintf("%d - %d", (i-1)*width,(i*width))
> 
>             mtext(s)
> 
>             par(ask=TRUE)
> 
>       }
> 
> }
> 
>  
> 
> What I'd like to do is modify the function so that it stays within a
> loop
> and accepts right and left cursor keys (or h and l) to shift the
> current
> window backwards and forwards (with the q key causing a break from the
> loop).
> 
>  
> 
> Is this possible with the par(ask=TRUE) command?
> 
>  
> 
> Thanks,
> 
> Chris Paulse
> 
> 
> 	[[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
> 
> ______________________________________________
> 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


-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/




More information about the R-help mailing list