I am trying to follow the instructions here on how to create a dual y-axis plot (yes, I know). My code is here.
However, in the output some of the major grid lines are slightly misaligned (see the red box), whereas some of them are perfectly aligned. I am not sure what is causing this dilation of one of the plots. I rewrote the code on that site to understand it better and have possibly introduced a bug somewhere.
An easy fix would be to turn off grid lines on one of the plots, but that seems to be hiding the problem rather than fixing it.
> ticks$grobs[]$x <- ticks$grobs[]$x - unit(1, "npc") + tml
Error in Ops.unit(ticks$grobs[]$x, unit(1, "npc")) :
both operands must be units
Your code in the
gist doesn't run (and it's also a bit complicated).
To understand why the lines aren't aligned, consider this example:
Now in your graph you have (something like)
You shouldn't add a constant to each axis, the value needs to be proportional to the scale.