Hi,

I think there's a bug in errorbar in trying to use asymmetric
y-errorbars.  According to the docstring:

    xerr and yerr may be any of:

        a rank-0, Nx1 Numpy array  - symmetric errorbars +/- value

        an N-element list or tuple - symmetric errorbars +/- value

        a rank-1, Nx2 Numpy array  - asymmetric errorbars -column1/+column2

However, code below that tries to use the last of these options fails,
as shown in the example below.

from matplotlib import pyplot as P
import numpy as N
x = N.linspace(-3, 3, 100)
y = x**2
P.errorbar(x,  y,  yerr=N.c_[0.1*y,  0.2*y])
P.show()

This fails with:

Traceback (most recent call last):
  File "errorbar_test.py", line 7, in <module>
    P.errorbar(x,  y,  yerr=N.c_[0.1*y,  0.2*y])
  File "/usr/lib64/python2.5/site-packages/matplotlib/pyplot.py", line
1591, in errorbar
    ret =  gca().errorbar(*args, **kwargs)
  File "/usr/lib64/python2.5/site-packages/matplotlib/axes.py", line
3766, in errorbar
    barcols.append( self.vlines(x, lower, upper, **lines_kw) )
  File "/usr/lib64/python2.5/site-packages/matplotlib/axes.py", line
2528, in vlines
    for thisx, (thisymin, thisymax) in zip(x,Y)]
ValueError: too many values to unpack

If I change yerr instead to (0.1*y, 0.2*y), which isn't listed as an
option, I get my desired behavior.  Looking at the code, it seems to
come down to lines 3757-3764 in axes.py:

       if iterable(yerr) and len(yerr)==2 and iterable(yerr[0]) and
iterable(yerr[1]):
            # using list comps rather than arrays to preserve units
            lower  = [thisy-thiserr for (thisy, thiserr) in
cbook.safezip(y,yerr[0])]
            upper  = [thisy+thiserr for (thisy, thiserr) in
cbook.safezip(y,yerr[1])]
        else:
            # using list comps rather than arrays to preserve units
            lower  = [thisy-thiserr for (thisy, thiserr) in
cbook.safezip(y,yerr)]
            upper  = [thisy+thiserr for (thisy, thiserr) in
cbook.safezip(y,yerr)]

This code would actually seem to preclude the use of an Nx2 array, so
something probably needs to be changed to bring the docstring and the
code into agreement.

Thanks,

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to