Mathematica: two synchronous animations

Click For Summary

Discussion Overview

The discussion revolves around creating two synchronized animations in Mathematica, specifically using ListLinePlot and ListAnimate. Participants explore methods to control both animations with a single slider for presentations, addressing issues related to implementation and functionality.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant seeks a method to synchronize two animations using a single slider for manual control during a presentation.
  • Another participant suggests using Grid within Manipulate to achieve the desired synchronization.
  • A different approach involves using Manipulate with Dynamic to control the animations, allowing for real-time updates.
  • A participant encounters an issue where their animations turn red, indicating a potential error in their implementation.
  • There is a suggestion to check for error messages and ensure the provided code runs correctly without modifications.
  • One participant speculates that the issue may arise from the different ways their animations are defined compared to the suggested code.
  • Another participant argues that ListAnimate may not be suitable for synchronized display, recommending the use of Show with a variable instead.

Areas of Agreement / Disagreement

Participants express differing views on the effectiveness of ListAnimate for synchronization, with some suggesting alternative methods. The discussion remains unresolved regarding the best approach to achieve the desired outcome.

Contextual Notes

Participants mention potential issues related to the definitions of their animations and the need for proper control variables in Manipulate. There is uncertainty about the specific implementation details that may lead to errors.

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 ·
Replies
5
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 2 ·
Replies
2
Views
4K
Replies
1
Views
2K
  • · Replies 52 ·
2
Replies
52
Views
13K
  • · Replies 3 ·
Replies
3
Views
6K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
9K