Sometimes, it's nice to create something in Tableau that doesn't necessarily have a practical use. I often find myself thinking, "Would this be possible in Tableau?", and just for the fun of it I'll sometimes try it. One particularly useless question would have been: is it possible to "draw" images and pictures in Tableau? And you've guessed it: it is indeed possible.
After all, to a computer, images and pictures are basically a set of coordinates and a color assigned to it. That is, in a very simplified interpretation. All we'll need to accomplish this challenge is to transform the picture into a set of readable information (coordinates and color) for Tableau. Now, turns out there is a piece of software that does exactly that.
Enter ImageMagick, which is software that allows you to manipulate bitmap images in a lot of different ways. One thing it can also do, is convert an image to a .txt file! If you install ImageMagick, you can easily follow the steps below (or even convert the picture through command line, if you want to do a bunch of them). Animated example below.
- Fire up ImageMagick Display (the GUI to the software).
- Open an image of your choice, which you wish to "visualize" in Tableau.
- Go to "File" > "Save As..."
- Save the image as a .txt file by:
- Selecting "Save as type": All Files.
- Appending ".txt." at the end of the filename in the text box above.
- You just converted an image to a text file! Open it to check the contents.
And this is what this text file looks like, format-wise. You'll find we have the coordinates on the left, and then three different ways of defining the colors for those pixels:
Let's import this file in Tableau! We do have a few settings to tweak in our data connection screen before the data is usable:
Yeah, that's not exactly what we need... Going through the following steps will help us get the data in the right shape. Again, animated version below.
- In the text file connection settings (Text File Properties), set the field separator to Space instead of "#".
- Split columns F1 and F4 using Tableau's super-useful "Split" functionality
- Rename the newly create columns adequately:
- X (the X-coordinate of the point)
- Y (the Y-coordinate of the point)
- R (the Red color value of the point)
- G (the Green color value of the point)
- B (the Blue color value of the point)
Once we've done this, we can go to Sheet 1 and start playing! Basically, follow these steps to obtain a (black and white) Tableau-rendered version of your picture! And once more, animation below.
- Convert the dimensions X and Y to continuous.
- Drag R, G and B to measures to turn them into continuous measures.
- Create a calculated field "Negative Y" that contains simply the inverse of Y:
- Drag X to the Columns shelf.
- Drag Y to the Columns shelf.
- Drag any of the color measures (R, G or B) to the Color mark.
- That's your picture!! In green, most likely...
- To change to grayscale, simply change the settings of the color mark by double clicking the color legend.
You might notice some weird actions in the recording above. For example, Show Me is being used instead of just dragging and dropping the pills to their appropriate place (Rows, Columns). Similarly a color is being double clicked and sent to the Size mark, then transferred to the Color mark, instead of dragging it there. This is because of a limitation of the screen recording software that was being used, which apparently did not allow drag and drop in Tableau. That's a bit annoying, as 50% of everything one does in Tableau is dragging and dropping stuff... Nevertheless, I think we got a nice example of how all roads lead to Rome, especially in Tableau!
Anyway, you just learned one of the most useless tricks in Tableau, but you can start having a lot of fun by importing all kinds of different pics into Tableau and playing with the color settings! And perhaps you'll end up with a .gif like this, that was created in Tableau!