# Contour lines by joining a set of 2D ordered points without line intersection

I was recommended on StackOverflow to ask this question here: for me it's dataviz question, but perhaps it's more algorithmic in nature.

I have an ordered set of points in 2D, and would like to join them using some sort of spline to form a closed loop that does not intersect itself. This is, in fact, a single contour line, and I have additional sets of points marking out further contour lines that should be sequentially nested inside each other. Do any dataviz procedures exist to do this without intersection? For instance, take the 23 black points in this picture as the outer contour and the 12 blue points as an inner contour.

I would want to join them vaguely like this:

If it helps, I'll probably be trying to visualise this in R.

• It would be far better to begin with the data from which the contour line was generated. Do you have those data? – whuber Jun 18 '14 at 14:48
• @whuber: thanks, but unfortunately for your suggestion, these are the data. They are points positioned along branches on a fractal tree (actually one of these). The "contour line" is purely to visualising how far along each branch you have travelled (in this case, a geological date). – user2667066 Jun 18 '14 at 15:02
• Why are there two of each point number (except the highest)? How exactly are these numbers related to the tree? If you do have a tree, that is extremely useful information so it would be good to know exactly what your original input is. – whuber Jun 18 '14 at 15:05
• The number is simply the order I wish to join the points: there is no correspondence between the black (1) and the blue (1) in my diagram. I agree in principle about the tree, but I'm not sure how it would help in this case. For the gory details, have a look at one of the trees at onezoom.org. The nodes on the trees mark increasing geological time to the present (but time is not related to branch length). An instant of geological time corresponds to a set of points along the branches (time=0 corresponds to the leaves on the tree). I wish to draw isolines for time around the tree. – user2667066 Jun 18 '14 at 15:15
• What do the black and blue colors in your diagram mean, then, and why do you draw two isolines? An alternative approach to your situation might be to draw a set of parallel linear (or perhaps concentric circular) isochrones and then arrange the nodes along each of them in breadth-first order, finally connecting those into the tree. In effect this distorts the tree in a continuous manner so that the isochrones become simple, which might be a superior way to visualize the temporal aspect of these data. – whuber Jun 18 '14 at 15:22