How to calculate paper position from value

Is there a function I can use to calculate where a certain value is with respect to the paper of a plot [0,1]?
For example, if the value “40” is in the middle of the yaxis, is there a function which will return “0.5”?
I have seen the yaxis.l2p() function in a few examples, but that one returns pixels instead of paper coordinates.

If you have pixels you first have to convert them with p2r and then r2fraction like this

layer._fullLayout.xaxis.r2fraction(layer._fullLayout.xaxis.p2r(“pixels”))