[Math] 3D correlation visualization

3dcorrelationvisualization

Incomer per person (x axis) correlates with life expectancy (y axis).
These two indicators change over time (z axis).

x correlates with y. Moreover, x and y both correlate with z.

The question is: what kind of plot should I use to visualize this? Maybe a 3D scatter plot?

Best Answer

A three-dimensional scatter plot is good, but can sometimes be hard to interpret because you lose a dimension of information when you project it onto the two-dimensional page.

An alternative is to do multiple two-dimensional scatter plots. This is equivalent to making a three-dimensional plot and then looking at it from different angles. For example, in R you can generate some data using

> X = rnorm(100)
> Y = rnorm(100) + X
> Z = rnorm(100) - X

and collect it together into a single data frame object

> D = data.frame(X=X,Y=Y,Z=Z)

You can generate the sample correlation matrix with

> cor(D)
           X          Y          Z
X  1.0000000  0.7647313 -0.7487290
Y  0.7647313  1.0000000 -0.5407474
Z -0.7487290 -0.5407474  1.0000000

and finally generate the set of two-dimensional scatter plots

> plot(D)

enter image description here

Related Question