Before I delve into my method, I should clarify the slight falsification in the title of this blog. Plotting perfectly in three dimensions, in Tableau, is impossible. This is not because of Tableau’s limitations, but is a consequence of that fact that computer screens are two-dimensional representations. It is impossible to plot anything in three dimensions. Even if we were to create 3-dimensional holograms they would still not be especially useful, because people can only see 2-dimensional projections of the 3D world. So, when I say this blog is about plotting in 3D, I mean it is about plotting 3-dimensional data on a 2-dimensional screen in a way that creates the illusion of 3-dimensionality.

In this respect I am not proposing anything remotely radical. Tableau already possesses a myriad of ways to visually represent 3-dimensional (and higher) data. Changing mark colour by a dimension on a scatterplot, for example, is a way of visually encoding third-dimensionality. The same could be said for changing the mark size, layering dimensions using measure values, plotting on dual axes, and a huge variety of other techniques. The method that I will introduce in this blog is an option to create a visualisation of 3-dimensional data that aims to add to these existing methods. But before I talk about my solution, I will have to talk in more detail about the problem.

3D Plotting in Tableau

Tableau is software that is capable of rendering almost any visualisation. For example, here is a rendering of a cute dog, visualised entirely in Tableau.

This visualisation was created using 2-dimensional data. Each pixel has an X and a Y coordinate, and a greyscale lightness value at each coordinate. However, it is interesting to note that this image possesses the illusion of 3-dimensionality. The original photo from which the data was created had a perspective and a light source that created shadows. These components enable us to recognise this dog as existing in three dimensions, even though the image exists only in two.

Conversely, here is a Tableau rendering of a dog, created from 3-dimensional data.

This dog is far less recognisable. It was created from a 3D model of a dog. The X and Y axes have been used to plot the data, and the Z axis has been used to colour the points (so that points close to the viewer are darker than points far from the viewer). This is one of the techniques I mentioned that Tableau can used to deal with 3D data. However, this dog does not look like a good representation of a dog. This is for a two main reasons.

Firstly, the rotation of the dog is strange. The way this model is oriented, we are looking at the dog from below, with its feet and belly closest to us. This illustrates a problem of visualising 3D data – the spatial orientation of that data heavily influences how we view its 2D representation. In the case of 3D models, this orientation is essentially arbitrary. In the case of meaningful data, for example a 3D representation of actual, budgeted and forecast revenue, the orientation is not arbitrary but it still reveals only one slice of the whole 3-dimensional picture.

Secondly, our perspective of the dog is skewed. Or perhaps I should say it is not skewed (and it should be). In regular vision, our perspective influences the appearance of distance. Far away objects appear smaller than close ones. The above method of viewing three dimensions, by squashing down the Z axis and representing it using colour, avoids this consequence of vision, and thus objects appear distorted (or indeed, are not as distorted as they should be).

A Solution Using Alteryx

I have built an Alteryx macro that deals with some of these problems. You can find it, and the visualisations from this blog, here. Documentation for how to use the macro is included in the repository’s README. The macro operates by rotating the data along the X and Y axes and taking a number of projections of that data. This can then be loaded into Tableau. Below are two plots generated using data from this macro. One uses perspective projection, wherein far away shapes are considered smaller (mathematically, they are scaled by value along the Z axis). The other plot does not use perspective projection.

While some of the projections look similar, some are also drastically different between the perspective and non-perspective projections. Particularly the front-on and rear-on views look stranger on the right, non-perspective projection, than they do on the left. By virtue of this projection and rotation algorithm, we now have a much better 3-dimensional picture of what the data looks like. However, as I will explain, this picture is far from perfect.

Limitations of this Projection Method

While this illustration looks good, there are two significant drawbacks. Firstly, this macro is designed to visualise data at the row level. I used an Alteryx macro to perform this process since I wanted to be able to automate it for multiple data sets, and because the operations would be very difficult to implement in Tableau (if they are possible at all). For this reason, the data in Alteryx must be aggregated to the level that you want to visualise it at. The macro is designed to output dimensions for Tableau columns and rows, rather than measures on columns and rows and a dimension on the details tab of the marks card. While this is not a huge disadvantage, it means the macro requires some data preparation in Alteryx before it is used.

Secondly, and more significantly, while this tool is very useful for showing the shape of 3D data, it is a poor tool for showing exact values of that data. This is frustrating, because most of the time the comparative values of data are more important than the shape of the data itself. This is best illustrated with an example.

On the left of the above image is a plot generated using Tableau’s Superstore dataset. It has Profit on the X axis, Sales on the Y axis, and Discount on colour. From this plot we can immediately gain a good idea of the relationship between Sales, Profit and Discount. On the right is the same plot created using the projection macro. Sales and Profit are set as the initial X and Y axes, and Discount is set as Z. The macro has then iteratively taken perspective projections of the rotating data. This plot does give us a better idea of the 3D distribution – the top left plot (which is of the original orientation) gives a similar picture to the unprocessed plot on the left. We can also see the data from various other angles. However, it seems to me that this level of detail is unnecessary and confusing for this visualisation. I can gain a better understanding of the relationship between Sales, Profit and Discount by looking at the plot on the left as opposed to the plot on the right.

This is down to several other disadvantages of this approach. In order to rotate and place a perspective viewpoint, the 3D projection macro has scaled the data to between 0 and 1 in all dimensions. Moreover, the rotations cause these axes to be uninterpretable. For example, while the Y-axis in the left figure clearly represents Profit, what meaning does a 45 degree rotation around the Sales axis have? Similarly, the perspective distortions to give the impression of 3D data also cannot be meaningfully interpreted in terms of that data. This lack of interpretability is a significant problem. While one could include the original values – Sales, Profit and Discount – as a tooltip or label on the right-hand plot, this approach defeats the purpose of visualisation. If I have to read the labels of tooltips to understand the data, I might as well just read the data table in excel!

I do not believe that these disadvantages make this macro completely useless. It simply has its own time and place. The macro’s rotation and projection approach is best situated to datasets where the shape of the data is more important that its values or interpretation. The 3D model of a dog was a clear example. Other examples might include models of objects or networks, or a machine learning or statistics scenario where knowing the distribution of the data is important. I acknowledge that those applications are not particularly common (at least in business intelligence). However, I will be waiting patiently for the opportunity to use this macro – and I hope you will too!

The Data School
Author: The Data School