6

I have lost ability to plot against datetime object after upgrading of matplotlib.

Error is following:

  File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/pyplot.py", line 2813, in plot
    is not None else {}), **kwargs)
  File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/__init__.py", line 1810, in inner
    return func(ax, *args, **kwargs)
  File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 1611, in plot
    for line in self._get_lines(*args, **kwargs):
  File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 393, in _grab_next_args
    yield from self._plot_args(this, kwargs)
  File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 370, in _plot_args
    x, y = self._xy_from_xy(x, y)
  File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 204, in _xy_from_xy
    bx = self.axes.xaxis.update_units(x)
  File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axis.py", line 1475, in update_units
    self.set_units(default)
  File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axis.py", line 1548, in set_units
    self._update_axisinfo()
  File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axis.py", line 1490, in _update_axisinfo
    info = self.converter.axisinfo(self.units, self)
  File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/pandas/plotting/_converter.py", line 353, in axisinfo
    majfmt = PandasAutoDateFormatter(majloc, tz=tz)
  File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/pandas/plotting/_converter.py", line 367, in __init__
    self._tz._utcoffset = self._tz.utcoffset(None)
AttributeError: 'datetime.timezone' object has no attribute '_utcoffset'

Is it possible to upgrade without loosing capabilities in Python?

Dims
  • 47,675
  • 117
  • 331
  • 600
  • I would also test it without Anaconda – David Arenburg Dec 25 '18 at 17:38
  • Possible duplicate of [How to handle times with a time zone in Matplotlib?](https://stackoverflow.com/questions/22255356/how-to-handle-times-with-a-time-zone-in-matplotlib) – Nick Chapman Dec 25 '18 at 17:38
  • I think these tickets [#12310](https://github.com/matplotlib/matplotlib/issues/12310), [#22859](https://github.com/pandas-dev/pandas/issues/22859) capture the issue, and not yet fixed. – Andrew Medlin Mar 01 '19 at 06:03

1 Answers1

2

I think a viable workaround is indicated by this question. Basically, if you convert the pandas timestamps to str and then back to datetime, it magically works.

Andrew Medlin
  • 461
  • 3
  • 11