-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Description
plt.errorbar
seems to dislike pandas Dataframes since matplotlib 1.5.0.
Here is the full code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plot
df = pd.DataFrame(np.random.rand(10, 2))
plt.errorbar(df[0], df[1], 'o')
which produces the following error:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-21-8f3d736d3f20> in <module>()
----> 1 plt.errorbar(df[0], df[1], 'o')
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/pyplot.pyc in errorbar(x, y, yerr, xerr, fmt, ecolor, elinewidth, capsize, barsabove, lolims, uplims, xlolims, xuplims, errorevery, capthick, hold, data, **kwargs)
2828 xlolims=xlolims, xuplims=xuplims,
2829 errorevery=errorevery, capthick=capthick, data=data,
-> 2830 **kwargs)
2831 finally:
2832 ax.hold(washold)
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/__init__.pyc in inner(ax, *args, **kwargs)
1809 warnings.warn(msg % (label_namer, func.__name__),
1810 RuntimeWarning, stacklevel=2)
-> 1811 return func(ax, *args, **kwargs)
1812 pre_doc = inner.__doc__
1813 if pre_doc is None:
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc in errorbar(self, x, y, yerr, xerr, fmt, ecolor, elinewidth, capsize, barsabove, lolims, uplims, xlolims, xuplims, errorevery, capthick, **kwargs)
2961 # using list comps rather than arrays to preserve units
2962 lower = [thisy - thiserr for (thisy, thiserr)
-> 2963 in cbook.safezip(y, yerr)]
2964 upper = [thisy + thiserr for (thisy, thiserr)
2965 in cbook.safezip(y, yerr)]
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/cbook.pyc in safezip(*args)
1492 for i, arg in enumerate(args[1:]):
1493 if len(arg) != Nx:
-> 1494 raise ValueError(_safezip_msg % (Nx, i + 1, len(arg)))
1495 return list(zip(*args))
1496
ValueError: In safezip, len(args[0])=10 but len(args[1])=1
Interestingly, the code works if I replace errorbar
by plot
.
Metadata
Metadata
Assignees
Labels
No labels