Our Blog

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.

Step 1: Download and install Processing

I’m not going to pretend to know what else one would use Processing for, but to complete this exercise, download the software here.

Step 2: Find an image

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.

Step 3: Run some code

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:

  • Make sure your image is loaded into Processing
    • Sketch–>Add File–>Find your resized images–>Open
    • Change line 4 of the code to reference the image name that you just loaded
    • Change line 8 to match the file type of the image you just loaded
  • Press the Play button or Ctrl+R to run the code
  • If everything was successful, you should see some random looking numbers showing up near the bottom of your screen
  • Go to Sketch–>Show Sketch Folder–>txtfiles

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!

Step 4: Add an index

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.

Step 5: Do some Tableau

Claiming ignorance again… I don’t even know what the Processing data really means, I just know it makes pretty pictures in Tableau.

  • Create bins from F3… I used 65 as my bin size because that is what George did
  • Create a calculated field that is simply -F3
  • Add F1 to Columns as a continuous dimension
  • Add F2 to Rows as a continuous dimension
  • Add the binned field to color
  • Add the calculated field to size
  • Reverse the rows axis

You should now see something like this

Step 6: Add some context

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

Comments ( 0 )

    Leave A Comment

    Your email address will not be published. Required fields are marked *