From an external simulation program, I have lots of particle tracks which follow random walks, all of which start at or near the origin $(0,0)$. This means that when I plot the walks in Mathematica, it looks a bit of a mess because all the tracks overlap with each other.
For example:
randomwalks = Table[
Accumulate@RandomVariate[StableDistribution[1, 1.7, 0, 0, 2], {512, 2}],
{i, 3}];
ListLinePlot[randomwalks, PlotRange -> Full, PlotTheme -> "Minimal",
Axes -> None, Frame -> True, AspectRatio -> 1];
This gives the image on the left - the fact that all the walks start near the origin means that they overlap and it's hard to see what is going on.
What I'd like to plot instead is something like the image on the right, where the random walks have been manually translated to stop them overlapping.
Is there a way to achieve this translation automatically with Mathematica?
The direction of each jump in the random walk is important, so I want to keep this in the visualization (hence translations only and no rotations).
Note also the choice of a Lévy-stable distribution for the random walk rather than the normal distribution. This typically gives walks that are more spread-out with longer jumps (due to the fat distribution tails). In turn this leads to a more diverse spread of shapes to try and fit together, and means arranging the shapes in a simple grid (e.g. via Column[Graphics /@ Line /@ randomwalks]
is not always as successful as I'd like.
My first thought was to calculate the bounding rectangle for each track, and then use the code in An algorithm to space out overlapping rectangles? to space out those bounding rectangles. However, this might leave large regions of whitespace due to the nature of the random walks, so perhaps a bounding polygon might be better to give a tighter arrangement of the tracks.
Given I have the track data itself, is there perhaps a way to do it without using the bounding rectangles? As suggested in a comment, perhaps using the convex hull of each path and then packing the resulting polygons?
regions = ConvexHullMesh[#] &/@ randomwalks
centroids = RegionCentroid[#] &/@ regions
Once we have the centroids, one approach would be to minimize the Euclidean distance between each centroid whilst ensuring the regions don't overlap - but that would need a function such as RegionOverlapQ[]
or similar.
ConvexHull[ ]
.) $\endgroup$Column[Graphics /@ Line /@ randomwalks]
or something? $\endgroup$