10000 Regression: "TypeError: Period('2000-12-31', 'D') is not a string" when a Series with date index was plotted · Issue #11623 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Regression: "TypeError: Period('2000-12-31', 'D') is not a string" when a Series with date index was plotted #11623
Closed
@toobaz

Description

@toobaz

Bug report

Bug summary

If I plot a pandas Series with dates index and then try to plot a simple line, I get a TypeError.

Code for reproduction

In [3]: from matplotlib import pyplot as plt

In [4]: import pandas as pd

In [5]: s = pd.Series(range(10), index=pd.date_range(start='2000-12-31', periods=10, freq='D'))

In [6]: s.plot()
Out[6]: <matplotlib.axes._subplots.AxesSubplot at 0x7f1bfdcb1c88>

In [7]: plt.plot(["2001-01-01"], [-5])
Traceback (most recent call last):
  File "/home/nobackup/repo/matp
62DA
lotlib/lib/matplotlib/cbook/__init__.py", line 290, in process
    proxy(*args, **kwargs)
  File "/home/nobackup/repo/matplotlib/lib/matplotlib/cbook/__init__.py", line 137, in __call__
    return mtd(*args, **kwargs)
  File "/home/nobackup/repo/matplotlib/lib/matplotlib/lines.py", line 635, in recache_always
    self.recache(always=True)
  File "/home/nobackup/repo/matplotlib/lib/matplotlib/lines.py", line 639, in recache
    xconv = self.convert_xunits(self._xorig)
  File "/home/nobackup/repo/matplotlib/lib/matplotlib/artist.py", line 186, in convert_xunits
    return ax.xaxis.convert_units(x)
  File "/home/nobackup/repo/matplotlib/lib/matplotlib/axis.py", line 1521, in convert_units
    ret = self.converter.convert(x, self.units, self)
  File "/home/nobackup/repo/matplotlib/lib/matplotlib/category.py", line 53, in convert
    unit.update(values)
  File "/home/nobackup/repo/matplotlib/lib/matplotlib/category.py", line 188, in update
    raise TypeError("{val!r} is not a string".format(val=val))
TypeError: Period('2000-12-31', 'D') is not a string
Out[7]: [<matplotlib.lines.Line2D at 0x7f1be11ff898>]

Expected outcome

No error

Matplotlib version
The above is ran on last git, and works instead with matplotlib 2.0.0.

  • Operating system: Debian Linux (but the Debian packaged version, 2.0.0, works)
  • Matplotlib version: last git
  • Matplotlib backend : reproduced both with pdf and with module://ipykernel.pylab.backend_inline
  • Python version:3.5
  • Jupyter version (if applicable):5.4.0
  • Other libraries: up-to-date git pandas

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0