0
$\begingroup$

I am new to Mathematica, but already find it a very nice tool. Right now I am trying to create an animation of numeric data, where each frame corresponds to a distinct text file with a table-like content.

With one static frame (file) I can do the following:

file = "Desktop/d1.txt"
data = Import[file, "Table"]
ArrayPlot[data]

Now, with multiple frames (files) I have to somehow animate a list of 2D lists, e.g.:

files = { "Desktop/d1.txt", "Desktop/d2.txt", "Desktop/d3.txt" }
data = Map[Import[#] &, files]

ListAnimate is said to accept a list:

ListAnimate[data]

,but it does not display the bitmap and shows a box with an advancing position bar and text representation of the data[[1]] . I would like to playback all the files' content as consecutive bitmaps. Should I somehow rearrange my 2D lists and/or may be ListAnimate is the wrong function for that task and I should use something else?

$\endgroup$
2
  • 2
    $\begingroup$ 1) ListAnimate 2) there is no ArrayPlot in AnimateList/ListAnimate. So is ListAnimate[ArrayPlot/@data] what you need? $\endgroup$
    – Kuba
    Sep 14, 2013 at 11:49
  • $\begingroup$ I am sorry for the typo, indeed it is ``ListAnimate''. $\endgroup$
    – Student4K
    Sep 14, 2013 at 21:35

2 Answers 2

2
$\begingroup$

Here's an example that does work, like Kuba says you have to give ListAnimate a list of exactly the elements you want to cycle through.

ListAnimate[Table[ArrayPlot[RandomReal[1, {3, 3}]], {i, 100}], 10]

arrayplot

In your case:

ListAnimate[Map[ArrayPlot[Import[#,"Table"]] &, files]]

Observe that the real name of the function is ListAnimate and not AnimateList.

$\endgroup$
1
$\begingroup$

Another way to approach this is with Manipulate:

Manipulate[ArrayPlot[RandomReal[i, {5, 5}]], {i, 1, 100}]

This creates a slider that allows you to move through the various images. By clicking on the small + sign in the upper right you can choose autorun, and it will animate through the various data.

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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