-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Closed
Milestone
Description
The import of __future__.unicode_literals in matplotlib.dates causes an error when calling datetime.datetime.tzname() on a datetime created with tzinfo=matplotlib.dates.UTC:
>>> import matplotlib.dates
>>> import datetime
>>> dt = datetime.datetime(2000,1,1, tzinfo=matplotlib.dates.UTC)
>>> dt.tzname()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: tzinfo.tzname() must return None or a string, not 'unicode'
This causes issues when plotting with a date formatter:
>>> import matplotlib.pyplot as plt
>>> import matplotlib.dates
>>> plt.plot([700000], [0])
[<matplotlib.lines.Line2D object at 0x7fe41dbb4050>]
>>> plt.gca().xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%Z'))
>>> plt.show()
...
File .../lib/python2.7/site-packages/matplotlib/dates.py", line 589, in strftime
return cbook.unicode_safe(dt.strftime(fmt))
TypeError: tzinfo.tzname() must return None or a string, not 'unicode'
(I've omitted most of the call stack)
Matplotlib 1.5.3, Python 2.7.12, Linux
Installed from source
The issue doesn't exist in Matplotlib 1.3.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels