Mathematica Mathematica: two synchronous animations

AI Thread Summary
The discussion focuses on creating synchronized animations in Mathematica using ListLinePlot and ListAnimate. The user seeks to control two animations with a single slider for a presentation. Suggestions include using Manipulate with Grid or Dynamic to achieve this synchronization. However, issues arise when trying to use ListAnimate, as it does not allow for direct control by Manipulate. The consensus is that using Show with a variable instead of ListAnimate is necessary for proper synchronization.
MartinV
Messages
68
Reaction score
0
Hello everyone.

Using ListLinePlot and ListAnimate I have made an animation with a hundred frames or so. Also, I have an animated graph corresponding to that animation, plotting certain values. For my presentation, I would like to show the audience these two animations and for that reason I need these two animations to move in tandem. Is there a way to get two animations to be controlled by a single slider because I would need to stop the animation and manually control it in the interesting area.

Thanks for any help you may have.
Martin
 
Physics news on Phys.org
There are two ways I am aware of to do this. The first is using Grid inside Manipulate:

Manipulate[
Grid[{{Plot[Sin[f x], {x, -3, 3},
PlotRange -> {-1, 1}]}, {Plot[Cos[f x], {x, -3, 3},
PlotRange -> {-1, 1}]}}], {f, 0, 10}]

The second is to use a Manipulate together with a Dynamic:

Manipulate[F = f;
Plot[Sin[f x], {x, -3, 3}, PlotRange -> {-1, 1}], {f, 0, 10}]

Dynamic[Plot[Cos[F x], {x, -3, 3}, PlotRange -> {-1, 1}]]
 
This looks great. I will try it immediately. Thank you so much!:cool:
 
Hm. For whatever reason the result turns to red, as if something is wrong.

I make the first animation with ListAnimate[graphtable2], where graphtable2 is defined:
graphtable2 = Table[myplot1[j], {j, 1, M}], where myplot1 is defined:
myplot1[j] = ListLinePlot[{P[j], e[j], f[j], g[j]},...].

The other is a graph which plots the Table called Final, then adds red points to the current value, depending on the slider:

Manipulate[
Block[{spl = ListLinePlot[Final, PlotRange -> {...}]},
Show[spl, Graphics[{Red, PointSize[.02], Point[{Final[[j, 1]], Final[[j, 2]]}]}]]], {j, 1, M}]

As far as I can see, by putting these two in a Grid, then wrapping a Manipulate around it should work. What am I missing?
 
What is the error message?

Check and see if the code I sent runs correctly without modification. If it doesn't then what version are you using? If it does then try plotting your graphs outside of a manipulate with a fixed value for the input.
 
The code you send, Dale, works fine. I get two graphs and they both respond to the slider. It's my own that is having problems.

I think the problem may be that your graphs are both defined in the same way while my animations are formed differently. The one called graphtable2 is a Table and the ListAnimate command that I use doesn't specify which parameter the slider is controlling. So putting it all into Manipulate confuses Mathematica. At least that's my assumption. I could be wrong here.
 
ListAnimate is not going to be useful for your purpose. In order to get synchronous display you need to have both of your plots display the corresponding image for some variable, x. If you just use ListAnimate then there is nothing to control for Manipulate or react on for Dynamic. So you should use something like Show[ graphtable[[x]] ] instead of ListAnimate.
 

Similar threads

Replies
5
Views
3K
Replies
5
Views
2K
Replies
52
Views
12K
Replies
3
Views
6K
Replies
2
Views
2K
Replies
3
Views
9K
Back
Top