The third week of Makeover Monday in 2017 presented us with an interesting (or ridiculous) data set comprised of the tweets sent out by President-elect Donald Trump. It took me about five seconds to decide what I wanted to do… draw an image of Trump with Trump’s tweets. Here is how I used Processing and Tableau to do it.
First of all, let me give credit where credit is due. George is someone who tends to fly under the radar, but when he does make an appearance, his work always amazes me. The general concept of my viz came from one of George’s old blog posts, that was originally used to enter a t-shirt design contest for #data14.
For the technically sound, George’s blog post should be pretty sufficient, but let’s take a deeper dive and break the process into steps.
I’m not going to pretend to know what else one would use Processing for, but to complete this exercise, download the software here.
Per George’s recommendation, a square image works best, something I have also found to be generally true. I found a nice 500×500 image of Trump here. This is where the differences between my Trump viz and George’s work come into play. George’s work was designed to be art and only art, but what if we want to add context to our art? Jumping ahead here, but if we put a 500×500 px image into Processing, we will get a file with 250,000 rows. Ideally, we would want an image that is a perfect square of the number of records our Makeover Monday dataset has, 30,281. Since 30,281 is not a perfect square, I decided to shrink my image to the closest square with enough rows to cover our number of tweets, 175×175. If you are like me and don’t have any fancy software to resize images, go here to handle that step.
Open Processing and copy/paste George’s code from the blog post reference earlier. There are a few things to take note of if you want your image/data conversion to work:
In the txtfiles folder, you should see a .txt with the same name as the image you loaded into Processing. If you just want to make some art, that file is all you need and you can skip right to Tableau!
The goal of this exercise is to join our deconstructed image to our data set of Trump’s tweets. Since we know that we have one row per tweet, let’s just go ahead and add an index to each data set. I don’t have any fancy tools to take care of this for me, so all I did was bring both data sets into excel and add a 1..n row number to each. After doing this, we could either join the data together in Excel, or bring both data sets into Tableau and blend.
Claiming ignorance again… I don’t even know what the Processing data really means, I just know it makes pretty pictures in Tableau.
You should now see something like this
At this point you could stop, play with color, play with size and come up with a pretty cool data picture. What I wanted to do was to add some context to the image and size it by the impact of the tweet. Also, when I added the row index to the file of Trump tweets, I made sure to order the data by the tweet date field from oldest to newest. The Processing data starts in the upper left corner and works down and across, so if we join on ordered data, we can pick out dates that significant events happened. Little bit rambly there… sorry.
Anyway, at this point we can blend on our index and add data from the Makeover Monday set. I replaced the size field with number of retweets to pick out those tweets that, in theory, had the highest global impact. What I didn’t expect to see was the massive change in retweet behavior right around the time that Trump declared his candidacy! In the end, this viz reminded me of the famous infectious disease work from the Wall Street Journal.
Please feel free to message me if you’d like to do something similar and get stuck!
Thank you – Curtis