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

Pandas Series not supported as data kwarg #12971

Closed
stilley2 opened this issue Dec 10, 2018 · 5 comments
Closed

Pandas Series not supported as data kwarg #12971

stilley2 opened this issue Dec 10, 2018 · 5 comments

Comments

@stilley2
Copy link
Contributor

Bug report

Bug summary

Passing a pandas Series object to axes.plot as data doesn't work.

This used to work in matplotlib 2.

Code for reproduction

from matplotlib import figure
from matplotlib.backends.backend_agg import FigureCanvasAgg
import pandas as pd


if __name__ == '__main__':
    fig = figure.Figure()
    ax = fig.add_subplot(1, 1, 1)
    data = pd.Series(data=[0, 1], index=['xdata', 'ydata'])
    print(data['xdata'])
    print(data['ydata'])
    ax.plot('xdata', 'ydata', data=data, marker='o')
    canvas = FigureCanvasAgg(fig)
    canvas.print_figure('test.png')

Actual outcome

0
1
Traceback (most recent call last):
  File "test1.py", line 12, in <module>
    ax.plot('xdata', 'ydata', data=data, marker='o')
  File "/home/stilley2/anaconda3/envs/testmpl/lib/python3.7/site-packages/matplotlib/__init__.py", line 1805, in inner
    return func(ax, *args, **kwargs)
  File "/home/stilley2/anaconda3/envs/testmpl/lib/python3.7/site-packages/matplotlib/axes/_axes.py", line 1603, in plot
    for line in self._get_lines(*args, **kwargs):
  File "/home/stilley2/anaconda3/envs/testmpl/lib/python3.7/site-packages/matplotlib/axes/_base.py", line 393, in _grab_next_args
    yield from self._plot_args(this, kwargs)
  File "/home/stilley2/anaconda3/envs/testmpl/lib/python3.7/site-packages/matplotlib/axes/_base.py", line 342, in _plot_args
    linestyle, marker, color = _process_plot_format(tup[-1])
  File "/home/stilley2/anaconda3/envs/testmpl/lib/python3.7/site-packages/matplotlib/axes/_base.py", line 118, in _process_plot_format
    'Unrecognized character %c in format string' % c)
ValueError: Unrecognized character a in format string

Expected outcome

A plot with a point at (0, 1)

Matplotlib version

(installed using conda)

  • Operating system: Centos7
  • Matplotlib version: 3.0.1
  • Matplotlib backend: agg (but probably doesn't matter)
  • Python version: 3.7
  • Pandas version: 0.23.4
@ImportanceOfBeingErnest
Copy link
Member

Bisects to #10872

@timhoffm timhoffm self-assigned this Dec 10, 2018
@anntzer
Copy link
Contributor

anntzer commented Dec 10, 2018

Fixed by #10928, which is opened since 8 months ago.

@stilley2
Copy link
Contributor Author

Ah I missed that issue while searching. Should I close this one then?

@anntzer
Copy link
Contributor

anntzer commented Dec 10, 2018

Well, that PR is not merged yet (I'm just gently nudging other devs to merge it...), so this can stay open until one of the fixing PRs goes in.

@timhoffm
Copy link
Member

Will be fixed for 3.1 via #10928

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

No branches or pull requests

6 participants