by way of c.buhtz@posteo.jp
2015-07-28 17:31:49 UTC
I try to use a dates on the x-aches. With pure Python3 code it works
fine. BUt when I try to use this inside wxPython application on a
FigureCanvas it doesn't work. And I don't understand the difference
here.
This is the error
[err]
plot.plot([datetime.date(2015, 1, 7),
TypeError: descriptor 'date' requires a 'datetime.datetime' object but
received a 'int'
[/err]
This is the fine working pure Python3 code.
[code]
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import datetime
plt.plot([datetime.date(2015, 1, 7),
datetime.date(2015, 2, 5),
datetime.date(2015, 6, 2)],
[70.3, 60.1, 68.8])
plt.show()
[/code]
This is the piece of wxPython code that cause the error
[code]
# -*- coding: utf-8 -*-
import matplotlib.pyplot as pyplot
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as
FigureCanvas
from datetime import datetime
#...
class StatisticTab(wx.Panel):
def __init__(self, parent):
super(StatisticTab, self).__init__(parent)
panel = wx.Panel(self)
fig = pyplot.figure()
plot = self.fig.add_subplot(1,1,1)
plot.plot([datetime.date(2015, 1, 7),
datetime.date(2015, 2, 5),
datetime.date(2015, 6, 2)],
[70.3, 60.1, 68.8])
self.canvas = FigureCanvas(self, -1, fig)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(panel)
self.SetSizer(sizer)
[/code]
------------------------------------------------------------------------------
fine. BUt when I try to use this inside wxPython application on a
FigureCanvas it doesn't work. And I don't understand the difference
here.
This is the error
[err]
plot.plot([datetime.date(2015, 1, 7),
TypeError: descriptor 'date' requires a 'datetime.datetime' object but
received a 'int'
[/err]
This is the fine working pure Python3 code.
[code]
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import datetime
plt.plot([datetime.date(2015, 1, 7),
datetime.date(2015, 2, 5),
datetime.date(2015, 6, 2)],
[70.3, 60.1, 68.8])
plt.show()
[/code]
This is the piece of wxPython code that cause the error
[code]
# -*- coding: utf-8 -*-
import matplotlib.pyplot as pyplot
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as
FigureCanvas
from datetime import datetime
#...
class StatisticTab(wx.Panel):
def __init__(self, parent):
super(StatisticTab, self).__init__(parent)
panel = wx.Panel(self)
fig = pyplot.figure()
plot = self.fig.add_subplot(1,1,1)
plot.plot([datetime.date(2015, 1, 7),
datetime.date(2015, 2, 5),
datetime.date(2015, 6, 2)],
[70.3, 60.1, 68.8])
self.canvas = FigureCanvas(self, -1, fig)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(panel)
self.SetSizer(sizer)
[/code]
------------------------------------------------------------------------------