From: Gary Ruben <gazzar@em...> - 2004-04-22 10:40:29
Just a little follow-up point. The normal axis autoscaling, with "plot(t, s, 'b-')" commented out, doesn't take account of the errorbar extrema. That is, the errorbars extend beyond the autoscaled window, whereas the window should be scaled to fully contain the errorbars.
----- Original Message -----
From: "Gary Ruben" <gazzar@...>
Date: Thu, 22 Apr 2004 20:19:10 +1000
Subject: [Matplotlib-users] axis scaling anomaly
> Here's an example of my attempt to plot errorbar data with a series line of a different colour. This example reveals an anomaly with the axis scaling which may the sign of an underlying bug. If you comment out the "plot(t, s, 'b-')" line and run the example, the axes autoscale. If you run the example as is, the scaling changes for some reason.
> Gary Ruben
> from matplotlib.matlab import *
> t = arange(0.1, 4, 0.1)
> s = exp(-t)
> e = 0.1*randn(len(s))
> f = 0.1*randn(len(s))
> lines = errorbar(t, s, e, f, '.', capsize=4)
> set(lines, 'color', 'g')
> plot(t, s, 'b-')
> xlabel('Distance (m)')
> ylabel('Height (m)')
> title('Mean and standard error as a function of distance')
Sign-up for Ads Free at Mail.com
From: John Hunter <jdhunter@ac...> - 2004-04-26 14:55:34
>>>>> "Gary" == Gary Ruben <gazzar@...> writes:
Gary> Just a little follow-up point. The normal axis autoscaling,
Gary> with "plot(t, s, 'b-')" commented out, doesn't take account
Gary> of the errorbar extrema. That is, the errorbars extend
Gary> beyond the autoscaled window, whereas the window should be
Gary> scaled to fully contain the errorbars.
Hi Gary, it turns out there were two problems here, one trivial, one
less so. The trivial problem was that we were not callling
from Axes.errorbar. That's why you saw the effect of commenting and
uncommenting the plot command.
The deeper problem was that the errorbar caps are specified in points
but the errorbars themselves are in data coords. All lines know how
to transform themselves to display, but to properly autoscale the view
lim we needed to know the cap dimensions in data coords. The fix was
to modify axes.add_line to detect the case where the line data was not
in data coords and then get the line extent in data coords by doing
line coords -> display coords -> inverse data transform -> data
The short answer is it works now and will be included in the upcoming
0.53.1 bugfix release.