getasp=function() {
h = par('pin')[2]/diff(par('usr')[3:4])
w = par('pin')[1]/diff(par('usr')[1:2])
return (h/w)
}
plot(0:9, 1:10, type='n', log='y')
asp=getasp()
a=0; b=log(10)/10
abline(a=a, b=b)
x_abline = mean(par('usr')[1:2])
y_abline = a+b*x_abline
points(x_abline, y_abline)
text(x=x_abline, y=y_abline, sprintf('abline(a=%g, b=%g)', a, b), srt=atan(b*asp)/pi*180, pos=3)
The text is rather away from the line. I am not sure why it is off. Could anybody show me what computation is wrong?


