First, sorry for the long email.
I'm having a segmentation fault problem trying to use plot_date,
somewhere deep in matplotlib. After giving up trying to figure out what
was going wrong from within my real code, I wrote a minimal sample
to try to reproduce (or not) the problem; here it is:
import datetime as dt
import wx
import matplotlib as mpl
import wxmpl
class PlotPanel(wxmpl.PlotPanel):
def __init__(self, parent, *args, **kwargs):
wxmpl.PlotPanel.__init__(self, parent, wx.ID_ANY, *args, **kwargs)
self.set_crosshairs(False)
self.Figure = self.get_figure()
ax = self.Figure.add_subplot(111)
ax.clear()
ax.grid(False)
zerodate = dt.datetime(2001,2,15)
zero = mpl.dates.date2num(zerodate)
x = range(int(zero), int(zero)+11)
ax.plot_date(x,x) # Problem line; works fine with plot instead
of plot_date
self.draw()
class MainFrame(wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
self.PlotPanel = PlotPanel(self)
self.MainBox = wx.BoxSizer(wx.VERTICAL)
self.MainBox.Add(self.PlotPanel, 1, wx.EXPAND )
self.SetSizerAndFit(self.MainBox)
class App(wx.App):
def OnInit(self):
self.frame = MainFrame(None)
self.SetTopWindow(self.frame)
self.frame.Fit()
self.frame.Show()
return True
if __name__ == __main__:
print wx.__version__
print wxmpl.__version__
print mpl.__version__
app = App(0)
app.MainLoop()
This code runs fine with plot instead of plot_date (just like my
original code with the same substitution). But with plot_date, I get
(please note the versions I'm using):
wx.__version__ = 2.6.3.3
wxmpl.__version__ = 1.2.7
matplotlib.__version__ = 0.87.4
Traceback (most recent call last):
File debugplot_date.py, line 40, in ?
app = App(0)
File
//Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/wx-2.6-mac-unicode/wx/_core.py,
line 7700, in __init__
self._BootstrapApp()
File
//Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/wx-2.6-mac-unicode/wx/_core.py,
line 7352, in _BootstrapApp
return _core_.PyApp__BootstrapApp(*args, **kwargs)
File debugplot_date.py, line 30, in OnInit
self.frame = MainFrame(None)
File debugplot_date.py, line 23, in __init__
self.PlotPanel = PlotPanel(self)
File debugplot_date.py, line 18, in __init__
self.draw()
File
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/wxmpl.py,
line 1189, in draw
else:
File
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/backends/backend_wxagg.py,
line 61, in draw
FigureCanvasAgg.draw(self)
File
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py,
line 391, in draw
self.figure.draw(renderer)
File
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/figure.py,
line 532, in draw
for a in self.axes: a.draw(renderer)
File
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/axes.py,
line 1045, in draw
a.draw(renderer)
File
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/axis.py,
line 548, in draw
majorLabels = [self.major.formatter(val, i) for i, val in
enumerate(majorLocs)]
File
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/dates.py,
line 369, in __call__
return self._formatter(x, pos)
File
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/dates.py,
line 247, in __call__
dt = num2date(x, self.tz)
File
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/dates.py,
line 205, in num2date
if not iterable(x): return _from_ordinalf(x, tz)
File
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/dates.py,
line 156, in _from_ordinalf
hour, remainder = divmod(24*remainder, 1)
ValueError: need more than 0 values to unpack
Using winpdb, I determined that this line in dates.py get called 13
times before, on the 14th time, it causes a communication failure
between winpdb and the code.
Any ideas what's up? Thanks in advance,
DG
PS: I'm on a Mac, running system 10.4.7 with Python 2.4.3 (#1, Apr 7
2006, 10:54:33) [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642