Visualizing Facebook Friends: Eye Candy in R
Paul Butler got a lot of popularity from his beautiful Facebook Relationship graph, but surprised many people when he let it slip that he made the whole thing using R. Known as a statistics and analysis package, the thought that it could create graphs like that was unexpected. In a new blog post, he covers how he did it.
The solution was to manipulate the drawing order of the lines. I used a simple loop over my data to draw the lines, so it was easy to control which lines are drawn first using order(). I created an ordering based on the length of the lines, so that longer lines were drawn “behind” the shorter, more local lines. Then I used colorRampPalette() to generate a color palette from black to blue to white, and colored the lines according to order they were drawn.