1
$\begingroup$

I have managed to import data from an Excel XLSX file using Import.

dat = Import[
   "C:\\Users\\User\\Documents\\Conductance\\mathfile.xlsx", {"Data"}];

There are two columns of data from which I would like to produce a ListAnimate / Animate plot.

I tried something like this:

points = Table[ListPlot[dat[[1, b]], PlotRange -> All], {b, 1, 10}];
ListAnimate[points]

This produces an animation but no points are plotted. The first point appears correctly, the rest seem to plot only a point corresponding to the first col.

The original data is in the form of a normal number (col 1) and a number using scientific notation, e.g., 4e-5 (col 2). Do I have to format my data in a different format?

$\endgroup$
  • $\begingroup$ Mathematica does not recognize numbers formatted like 4e-5. However, I think the import expression converts such numbers to Mathematica reals. Can't be sure because I don't have access to Excel or any .xlsx files. $\endgroup$ – m_goldberg Jul 28 '17 at 14:39
  • 1
    $\begingroup$ @m_goldberg You can use Internal`StringToDouble, that recognizes that notation, and the importer uses that. $\endgroup$ – FJRA Jan 24 '18 at 20:17
3
$\begingroup$

For speed reasons, I would avoid ListPlot and just use Graphics directly. Here is some sample data:

data = Table[{x,Sin[x]},{x,0,10,.01}];

And, here is an animation:

Animate[
    Graphics[
        {Line[data[[;;i]]]},
        PlotRange->{{0,10},{-1,1}}
    ],
    {i, 1, Length[data], 1}
]

enter image description here

$\endgroup$
0
$\begingroup$
dat = Import["C:\\Users\\User\\Documents\\Conductance\\mathfile.xlsx"{"Data"}];
points = Table[dat[[1, j]], {j, 1, 10}];

tag = Table[ Take[points, n], {n, 1, 8, 1}];
Manipulate [ListPlot[tag[[c]]], {c, 1, 8, 1}]
$\endgroup$
  • 5
    $\begingroup$ points = data[[All, 2]] is really much better way to extract column 2. $\endgroup$ – m_goldberg Jul 28 '17 at 14:57

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.