Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Series.plot #97

Closed
dieterv77 opened this issue Aug 9, 2011 · 1 comment
Closed

Problem with Series.plot #97

dieterv77 opened this issue Aug 9, 2011 · 1 comment

Comments

@dieterv77
Copy link
Contributor

The code snippet below raises an AssertionError from pandas because matplotlib tries to add a dimension to the index ndarray subclass.
No big deal, since i can do
pylab.plot(np.asarray(ts.index), np.asarray(ts.values)

import pandas
import datetime
import numpy as np
values = np.arange(5.)
dates = [datetime.datetime(2009, 1, 1, 0, 0),
datetime.datetime(2009, 1, 2, 0, 0),
datetime.datetime(2009, 1, 5, 0, 0),
datetime.datetime(2009, 1, 6, 0, 0),
datetime.datetime(2009, 1, 7, 0, 0)]
ts = pandas.Series(values, index=dates)
ts.plot()

Here's the trace back:
Traceback (most recent call last):
File "pandasplot.py", line 11, in
ts.plot()
File "/usr/lib/python2.7/dist-packages/pandas/core/series.py", line 1189, in plot
ax.plot(x, self.values.astype(float), style, *_kwds)
File "/usr/lib/python2.7/dist-packages/matplotlib/axes.py", line 3783, in plot
for line in self._get_lines(_args, **kwargs):
File "/usr/lib/python2.7/dist-packages/matplotlib/axes.py", line 317, in _grab_next_args
for seg in self._plot_args(remaining, kwargs):
File "/usr/lib/python2.7/dist-packages/matplotlib/axes.py", line 294, in _plot_args
x, y = self._xy_from_xy(x, y)
File "/usr/lib/python2.7/dist-packages/matplotlib/axes.py", line 239, in _xy_from_xy
x = x[:,np.newaxis]
File "/usr/lib/python2.7/dist-packages/pandas/core/index.py", line 110, in getitem
return Index(arr_idx[key])
File "/usr/lib/python2.7/dist-packages/pandas/core/index.py", line 50, in new
assert(subarr.ndim == 1)
AssertionError

@wesm
Copy link
Member

wesm commented Aug 9, 2011

Thanks for reporting this. Should be fixed here:

wesm@e0a12b9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants