2
$\begingroup$

It's possible that this may be tagged as a duplicate question, but I have been searching this site and the rest of the internet for at least 2 hours looking for an answer to no avail.

I have a series of lists of 200 lines of x and y values (let's call them DataList1, DataList2, etc.) For example:

DataList1=[{150, 15745.7}, {152, 15571.2}, {154, 15401.}, {156, 15253.2}]

I used ListPlot on each individual list of x and y values which gives me a very nice graph (Graph1, Graph2, etc.) For example:

Graph1 = ListPlot[DataList1, PlotRange -> All, PlotStyle -> {RGBColor[1, 0, 0]}]

After creating each graph (and assigning a variable name to each graph) I would now like to use list animate to show one graph, then the next one, and so on. However, if I use the code:

ListAnimate[Graph1, Graph2, Graph3]

it does not create the animation box, it only shows a list of each plot as a thumbnail.

There are a total of 19 Graphs / Lists that are to be included in the series.

What am I doing wrong?????

Thank you in advance for any help!

$\endgroup$
  • $\begingroup$ How about ListAnimate@List[Graph1,Graph2, ...]? $\endgroup$ – Myridium Sep 14 '16 at 3:31
  • $\begingroup$ It's a good idea to look at the documentation first, before googling. The syntax shown there is ListAnimate[{expr1, expr2, ...}] and not ListAnimate[expr1, expr2, ...]. Those brackets are very very important. Pay attention to them. For example, your question above contains DataList1=[{150, 15745.7}, ..., which is not valid syntax and won't evaluate in Mathematica, all because of wrong use of brackets. $\endgroup$ – Szabolcs Sep 14 '16 at 12:42
  • $\begingroup$ It was indeed the missing brackets around my expressions. Thank you so much! $\endgroup$ – Lindsay Lesh Sep 15 '16 at 18:19
2
$\begingroup$

Since you did not give the data, I generate it:

lst = Table[Table[{x, x^a}, {x, 0, 10, 1}], {a, 0.1, 1, 0.1}];

Now, this is the list of plots:

table = ListPlot[#, PlotRange -> {0, 10},PlotStyle -> {RGBColor[1, 0, 0]}] & /@ lst;

You can evaluate it and have a look at the results. This makes the animation:

ListAnimate[table]

Try it. The result looks as follows:

enter image description here

I attract your attention to the requirement that the argument of the ListAnimate must be itself a List, as it is in my example and in the comment of Myridium.

On the other hand, if you give only a sequence of plots as the arguments of the ListAnimate(like this):

ListAnimate[table[[1]], table[[2]], table[[3]], table[[4]]]

Mma returns this

enter image description here

which is what you, probably, observed. The advise is, therefore to enter curly braces:

ListAnimate[{Graph1, Graph2, Graph3}]

Have fun!

$\endgroup$
  • $\begingroup$ Thank you!! That gives me a good template for the future! $\endgroup$ – Lindsay Lesh Sep 15 '16 at 18:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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