Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I would like to use Mathematica for a presentation and have a list plotted in front of my audience, one coordinate at a time.

How would I go about plotting a list progressively in real-time, ie the coordinates {1,y1} first, then one second after the coordinates {2,y2}, etc... ?

Something with Manipulate so that I could switch on and off this option would be nice, but I don't see any function in the documentation that would let me plot lists in real time.

share|improve this question
2  
I think you're confusing a few terms here... plotting in "real time" does not mean what your question describes. What you probably want is to display a pre-computed list of points sequentially, with a reasonable time delay, correct? If so, try using Manipulate (or Animate) by indexing the list in steps of 1. –  rm -rf Mar 3 at 15:48
    
list=RanomdInteger[10,10]; Animate[ListPlot[Take[list, i], PlotRange -> {{1, Length[list]}, {Min[list], Max[list]}}], {i, 1, Length[list], 1}] –  Szabolcs Mar 3 at 15:50
    
@rm-rf you're correct, I want to display a pre-computed list of points sequentially –  su1 Mar 3 at 15:56
    
@Szabolcs why is it that when I evaluate your commands the whole list is being plotted for a second and then after this delay only it starts plotting from x = 1? –  su1 Mar 3 at 16:34
    
@Stefan Well, that's why it was a comment and not an answer (despite the recent meta thread). I assumed the OP would sort out the details. –  Szabolcs Mar 3 at 17:38

1 Answer 1

up vote 2 down vote accepted

If you want to do display the list point by point, you can simply use the animation controls of the Manipulate and hit the little plus button beside the control. Then to increment you click the plus and to decrement you hit the minus. You can also "play" the animation, and pause it when you want it. There are also controls to slow down (or speed up) the animation.

Manipulate with animation controls open

Alternatively, if you want a button like control, the following code could do what you want.

    list = With[{k = .1}, Table[{t, Exp[-k t]}, {t, 0, 30}]];
    Manipulate[
     ListPlot[list[[1 ;; currentPoint]], PlotRange -> {{0, 30}, {0, 1}}, 
      PlotStyle -> {PointSize[Large], Red}], {{currentPoint, 1}, 0, 30, 1, 
      Row[{Button["Next Point", 
          If[currentPoint < 31, currentPoint++, currentPoint = 31]], 
        Button["Previous Point", 
          If[currentPoint > 1, currentPoint--, currentPoint = 1]]}] &}]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.