2 Y Axes in Algebra of Graphics

I have been trying to figure out how to make two separate y-axes for a plot in Algebra of Graphics. This seems possible in Makie, julia - Double y-axis on left and right side of plot in Makie.jl - Stack Overflow (though I think this example is old).

How would I do this in Algebra of Graphics?

The grammar of graphics is generally opposed to dual axes because it breaks the 1-to-1 mapping between locations and values. The only situation where it’s considered safe is when the two axes are monotonic transformations of each other, such as a Fahrenheit axis and a Celsius axis over the same values. I’m guessing AoG doesn’t support that currently.

1 Like

One way to handle this logically is to plot dimensionless ratios, so there are no units and everything is on a comparable scale.

For example suppose the two things you want to plot are the angle of a linkage rod that varies over about 10 degrees, and the force applied to it, both as time series… Instead of plotting say degrees and kilonewtons you take the data and convert to degrees/max angle, and force as a fraction of peak force for a cycle… Now you have values that are all in the range of about ±1 and can plot on a single dimensionless axis