Solved – How to compare dependent variables with different units using Grammar of Graphics paradigm

data visualizationggplot2

My data analysis workflow is through R and ggplot2, in part because ggplot2 discourages me from making 'bad' (misleading, etc.) plots. However, I sometimes would like to make plots that compare multiple unlike dependent variables against a common independent variable, like below:
enter image description here.

This is usually done by adding multiple axes. ggplot can't add multiple axes.

I realize that I have several ways around this: I could move out of ggplot for this type of plot, or I could probably hack something within ggplot.

My question is how I should deal with with this. The ggplot way to deal with this is by facetting, but often I want to facet by other variables. (For instance, with the pictured example, I might have collected the data at multiple locations and altitudes).

Is Grammar of Graphics just a bad paradigm for this kind of dataset, or is there some presentation option that would work well?

Best Answer

Call me a heretic, but I completely disagree with this flame war on double axes; yes, they can be extremely deceiving, but only when you plot two things of a same unit (i.e. when their sum or difference makes sense) -- then the plot suggest that they have an equal range, which is usually not the case (like income of two companies).
But if you have two different units, this problem cease to exist -- viewer's mind instantly rejects the idea that values are important and focuses on co-occurring patterns.
Also if you want to show a nonlinear and lagged correlation, scatterplots and ratio plots will be completely useless, autocorrelation may be inconclusive and will show only a fraction of information and facets will hide the nature of the lag -- I see no better option here:

enter image description here enter image description here

Moreover, double axes are great for a completely benign task of showing something in two linearly dependent units, like temperature in °C and K.

Finally, they are simply ubiquitous in physics (meteorology included) and engineering and none of those people feel wrong about it.

Related Question