Poudro's blog
CTO / Data Scientist / Problem Solver - Consultant

Retweet Map - poudro.com développeur web freelance


One thing I’ve been itching to do for a while is a visualisation of “retweets”. This is what I came up with.

Twitter’s streaming API is really my favorite API. If all search APIs were like this, the world would be a better place, IMHO.


Anyway, you can read all about the API here. I use the “statuses/filter” with a search string that should match pretty much any tweet written with Latin alphabet derivatives. The free (i.e. open to everyone) version of the Streaming API is not a complete subset of Twitter, there are some missing tweets, but it still gives a pretty good view. At the time of writing this, I’m receiving a little under 3000 tweets every minute. Out of every 3000, about 800 are retweets (have a “retweet_count” value greater than 0).

Next, we need to store these for future reference. Nothing fancy here, simple MySQL table with a unique key on the original tweet ID with the time and reweet_count. To prevent the table from becoming gigantic, a retweet is kept at most 10 minutes since it was last retweeted. A simple AJAX will take care of the fetch.

Check it out here.

The final part is the visualisation itself. How to represent the retweets? I’m interested in the number of times a tweet gets retweeted. A natural way of showing this is by showing a circle with radius dependant on the “reweet_count”. The circle then grows as the same tweet is retweeted over and over again. To prevent clutter, the opacity is slowly reduced to zero and the tweet disappears from the screen altogether after 1 minute without activity. By dragging your mouse over a circle, a box appears with information abour the tweet.




28 Mar 2013