Trying to get a linear graph.
If I understand the
thin lens equation, when the subject is at infinity, the image distance is equal to focal length.
When focusing towards macro, the image distance increases, and therefore, the lens must be moved a little far away from the sensor in order to keep the subject in focus.
If we assume the linear lens movement is proportional to the focus_pos counter, we should get a linear graph if we plot the image distance (instead of the focus distance). I'm just going to distort the axis (so the plot will show image distance, but the axis labels will show focus distance).
The Y axis transformation should be something like 1 / (1/f - 1/o), where f is focal length and o is focus distance (object distance in the above link).

I've played a bit with the focal length in the above formula, and if I use 200mm instead of the real value of 100mm, the graph is pretty much linear.
Is this because the thin lens equation doesn't quite apply here, or I'm just misunderstanding the whole thing and, and that linear graph was pure luck?
The 24/2.8 STM also gives a more linear plot with twice the actual focal length in the thin lens formula.

For 70-200/2.8 II, it's a tie.

For 35/2, 2*f looks better, and 3*f looks even better:

The 17-40/4 looks best when linearized with f=80mm, at all focal lengths.


Food for thought:
1. Assuming we can find a good linearization transform (e.g. by choosing the "fake focal length" to minimize linear fit errors or similar), which is a better approximation for the actual focus distance? The linear regression line, or the line connecting the center points of the horizontal segments in the above graphs?
This can be answered by somebody who can set up a test environment with known focus distances (e.g. a linear axis of a CNC machine or similar, that can be moved at known distances). One needs to get a log similar to the previous ones, with an extra column: the real focus distance.
2. Most lenses can focus past the infinity, and this is visible in the above graphs as well. Can we find the real infinity focus point without actually using a distant object to focus on? (assuming the focus distance markers are calibrated from factory).
These are probably nitpicks, not sure how useful they are in practice.