Description
Currently, when setting xlim(1231, 1239)
, the offset text is "+1.231e3" and the x labels are 0, ..., 8. I would suggest switching this to +1230 and x labels being 1, ..., 9. There is a formatting issue (basically using "%g" instead of "%f"), but I want to concentrate here on the actual value of the offset.
Basically, I think a reasonable algorithm for the choice of the offset value is the following:
(1) if xmin and xmax have the same number of digits: use the longest common prefix of their string representations, padded by zeros (e.g. xyzabc .. xyzdef => xyz000).
(2) if they don't have the same number of digits (e.g. 9995 .. 10005), I see two possibilities: either fall back to using 9995 as base offset, or use 10000 as base offset in which case the x labels will go from -5 to +5. I tend to think the second option is better but it is true that negative labels can look weird.
(3) note that using negative labels is also an option in case (1) if the number of zeros in the padding is "large" relative to the x range, e.g. 12399995 .. 12400005: it may be better to use 12400000 as base offset and have x labels from -5 to +5 rather than 12300000 as base offset and have x labels from 99995 to 100005.
Thoughts?