[R] Plot with pauses?

Greg Snow 538280 at gmail.com
Thu Nov 12 18:12:53 CET 2015


Here is one option if you don't want to write the explicit for loop
(there is still a loop):

library(TeachingDemos)
v<-0:60
z<-3/5+4i/5
t<-z^(v/9)
tmpfun <- function(npoints) {
  plot( Re(t)[seq_len(npoints)], Im(t)[seq_len(npoints)],
        xlab="Real", ylab="Imaginary", xlim=c(-1,1), ylim=c(-1,1),
        asp=1)
}
tkexamp(
  tmpfun,
  list(npoints=list('animate',from=0,to=length(t), resolution=1, delay=500))
)



On Wed, Nov 11, 2015 at 10:30 PM, Judson <judsonblake at msn.com> wrote:
> I'm trying to create a
> series of demos for students.
>
> It would be helpful
> if plotted data points
> could appear one by one
> with, say, half-second delays
> between points.
>
> For instance,
> code like this
>
> v<-0:60
> z<-3/5+4i/5
> t<-z^(v/9)
> plot(Re(t),Im(t))
>
> would be better if I
> could invoke some
> pausing between points
> so the student could see
> the progression of
> the process.  Many
> mathematical progressions
> might be more understandable
> if the viewer could see
> this happen over intervals
> of time.
>
> Naturally I'd like to
> avoid for loops if that's
> possible.
>
> I really don't know
> where to start my
> search.   Any suggestions?
>
> ..... judson blake
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Gregory (Greg) L. Snow Ph.D.
538280 at gmail.com



More information about the R-help mailing list