Darren Dale wrote:
A while back, I put some effort into rendering an offset ticklabel, which allowed the user to do something like
plot(linspace(100000100, 100000200, 100))
and the plot would look like a plot from 0 to 100, with a "+100000100" rendered in a new label near the far end of the axis. This doesnt work quite as well as it used to, because the axes autoscaling is setting the plot range to something like the average plus and minus 6%. I have tried tracing the source of this change, but I can't find it. It might be buried in the _transforms extension code, and I've never been able to wrap my head around mpl's transforms.
Does anyone know why autoscaling is defaulting to this +-6% range? Does it have to be this way? I'm trying to improve the scalar formatter (supporting engineering notation, cleaning up the code).
Yes. It is not a +-6% range in general, rather it is an adjustment that is made if the range is very small. The relevant method in Locator is:
def nonsingular(self, vmin, vmax, expander=0.001, tiny=1e-6):
if vmax < vmin:
vmin, vmax = vmax, vmin
if vmax - vmin <= max(abs(vmin), abs(vmax)) * tiny:
vmin -= 1
vmax += 1
vmin -= expander*abs(vmin)
vmax += expander*abs(vmax)
return vmin, vmax
I know I did it this way for a reason, but I don't remember exactly what it was--whether it was because of problems with zooming when the zoom range gets too small (this was definitely a big problem), or because of problems with the rest of the locator code, or because it seemed to me to be roughly the desired behavior in most cases. Maybe it was all of the above. Certainly, something like this is needed--I think you will find that things go bad rapidly if vmin gets too close to vmax. I put in the "expander" and "tiny" kwargs in case of future need, but only expander is non-default (e.g., 0.05) in other parts of ticker.py, and neither kwarg is presently exposed to the user. That could be changed.