# [R] xinch/yinch equivalent for log axis

From: Steven J. Murdoch <Steven.Murdoch_at_cl.cam.ac.uk>
Date: Tue 03 May 2005 - 02:53:43 EST

This code shows an example of what I mean[1]:

split.screen(c(2,1))
screen(1)
# Linear scale, works fine

plot(1:100, cex=0.5, pch=19)
plotheight <- diff(par("usr")[3:4])
igap = 0.5 # intended gap, in inches
gap <- igap/par("pin")[2]*plotheight # gap in user units lines(c(20,20),c(100,60+gap))
lines(c(20,20),c(60-gap,1))
points(20,60, pch=18)

screen(2)
# Logarithmic scale, point no longer centered
plot(1:100, cex=0.5, pch=19, log="y")
plotheight <- diff(par("usr")[3:4])
igap = 10
gap <- igap/par("pin")[2]*plotheight
lines(c(20,20),c(100,10+gap))
lines(c(20,20),c(10-gap,1))
points(20,10, pch=18)
close.screen(all=TRUE)

The top graph is as I want. The diamond is centered in the gap, and the gap is 1 inch high (2*igap).

In bottom graph, using a log scale, the diamond is no longer centered in the gap and there is a non-linear relationship between the gap height in inches and igap.

I understand why this is happening, and this is why the xinch and yinch functions raise a warning, but is there a way to handle it? For example, is there a function which will return the user coordinate of a point, x inches above a given point p (in user coordinates), for a logarithmic y axis?