# ListPlot of a complex data file

Here are some sample data:

data = {{1}, {50., 53, 52, 52}, {100., 105, 104, 104}, {150., 157, 156,
156}, {200., 209, 208, 208}, {250., 261, 260, 260}, {300., 313, 312,
313}, {2}, {50., 53, 52, 51}, {100., 106, 105, 102}, {150., 158,
157, 153}, {200., 211, 210, 204}, {250., 265, 264, 256}, {300., 319,
318, 307}, {3}, {50., 53, 52, 52}, {100., 106, 105, 104}, {150.,
158, 158, 156}, {200., 211, 210, 209}, {250., 264, 263, 261}, {300.,
317, 316, 313}, {4}, {50., 51, 50, 51}, {100., 102, 101,
102}, {150., 153, 152, 152}, {200., 204, 203, 204}, {250., 256, 256,
254}, {300., 309, 309, 305}, {5}, {50., 52, 51, 52}, {100., 104,
104, 104}, {150., 156, 155, 156}, {200., 208, 208, 208}, {250., 260,
260, 260}, {300., 312, 311, 312}}


As we can see, there are five sets of four columns. Now we will delete the indices (1,2,3,4,5) and create the corresponding sub lists.

d2 = SplitBy[data, Dimensions][[2 ;; ;; 2]];


The first column is time, while the other three are some integers (nx, ny, nz). I want to see the time-evolution of these integers. In particular, I want to ListPlot all five nx versus time in a single plot (one on top of each other). Then I suppose it would be trivial to do the same for ny and nz versus time.

Any suggestions?

Make a function to select $n_x,n_y,n_z$ from the $i^{th}$ data set

 p[i_, n_] := d2[[i, All, n]]


Another function to select all the time component

 t[i_] := d2[[i, All, 1]]


Combine them properly for ListPlot

 data[i_, n_] := Partition[Riffle[t[i], p[i, n]], 2]


For the $n_x$ component put $n=2$. Similarly you can plot it for $n=3,4$

 ListPlot[Table[data[i, 2], {i, 1, Length[d2]}], Frame -> True]


• Very nice! Thanks:) – Vaggelis_Z May 24 '16 at 16:53

I might have misinterpreted the question. So, please do correct me if I am wrong and I will amend my answer.

Based on my understanding, please see implementation below.

Example:

(*Extract all sub-lists who's length is exactly 4*)
data = (Select[raw, Length @ # == 4 &]);

(*Here I plot x, y and z sets vs time*)
ListPlot[data[[All, {1, #}]] & /@ {2, 3, 4}, PlotLegends -> {"x", "y", "z"}]


Note: raw is the initial data set from your OP.

Output:

• Unfortunately this is not what I want. What I want is to plot the time-evolution of all nx in a single plot. Do you see the difference? – Vaggelis_Z May 24 '16 at 16:40
• @Vaggelis_Z that's confusing.. I think this is what's plotted. X-axis is your time and three series correspond to {nx, ny, nz} – BlacKow May 24 '16 at 16:44