Mathematica: two synchronous animations

In summary, Dale, your animation looks great but you will need to use something else to synchronize the animation with the slider.
  • #1
MartinV
69
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
  • #2
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}]]
 
  • #3
This looks great. I will try it immediately. Thank you so much!:cool:
 
  • #4
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?
 
  • #5
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.
 
  • #6
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.
 
  • #7
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.
 

Related to Mathematica: two synchronous animations

1. What is Mathematica?

Mathematica is a software program used for mathematical and scientific computations. It also has built-in functions for data analysis, visualization, and programming.

2. How can I create two synchronous animations in Mathematica?

To create two synchronous animations in Mathematica, you can use the Manipulate function. This function allows you to manipulate variables and create dynamic animations based on those variables.

3. Can I customize the animations in Mathematica?

Yes, you can customize the animations in Mathematica by using different parameters and options in the Manipulate function. You can also add labels, titles, and other visual elements to make the animations more informative and visually appealing.

4. Is it possible to export the animations created in Mathematica?

Yes, you can export the animations created in Mathematica to various formats such as GIF, MP4, and HTML. This allows you to share your animations with others or use them in presentations or reports.

5. Are there any resources available to learn how to create animations in Mathematica?

Yes, there are many resources available online to learn how to create animations in Mathematica. You can refer to the official Mathematica documentation, tutorials, and online forums for help and support. There are also online courses and books available for a more in-depth understanding of Mathematica and its animation capabilities.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
682
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
4K
  • Programming and Computer Science
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
6K
  • MATLAB, Maple, Mathematica, LaTeX
2
Replies
52
Views
12K
  • Special and General Relativity
Replies
6
Views
1K
Back
Top