# list manipulation – Plot trajectories of 1D coalescing particles: Reshape irregular size array

My question boils down to:
How can I reshape a list composed of sublists of different sizes?

I am trying to plot the trajectories of 5 particles (1D), and if they collide, they merge into one same particle.

After running the simulation, I end up with a data set composed of sublists, where each sublist corresponds to the position of each particles. For example:

``````data={{3, 5, 4, -5, -3}, {3, 5, 3, -5, -3}, {4, 5, -5, -3}, {4,
5, -5, -2}, {4, 5, -5, -3}, {5,
5, -5, -3}, {6, -5, -3}, {6, -6, -3}, {6, -6, -4}, {6, -7, -4}}
``````

where `data(t)` represents the position of the five particles at time $$t$$. The main problem is that as time evolves, the size of `data(t)` is not the same. For example from `data(5)` onward there are only 3 particles remaining. So I cannot transpose my dataset to to a list plot.

In this particular situation I guess I would like to obtain the following:

``````newData={{3, 3, 4, 4, 4, 5, 6, 6, 6, 6}, {5, 5, 5, 5, 5, 5}, {4,
3}, {-5, -5, -5, -5, -5, -5, -3, -3}, {-3, -3, -3, -2, -3, -3, -3,
-3, -4, -4}}
plot = Rotate(ListLinePlot(newData), -90 Degree)
`````` Non essential question: would it be possible two only have one colour for each tree?

Posted on Categories Articles