embedding in wx segfault

Hi I have a variant of the embedding_in_wx script that worked fine on my previous version of matplotlib. Now, with version 0.51 it’s seg faulting. I updated the script to reflect the changes in the library but still… Can anyone see what may be going wrong?

thanks

here is my script:

···

Name: PlotFigure.py

Purpose: Plotting frame that contains the plots generated by Model Buider

Author: Flavio C. Coelho

Created: 2004/09/01

RCS-ID: $Id: PlotFigure.py,v 1.1 2004/01/13 10:51:43 fccoelho Exp $

Copyright: © 2003

Licence: GPL

Obs: This code was based on Jeremy Donoghue’s embedding_in_wx.py included with

matplotlib.

#-----------------------------------------------------------------------------

#Boa:Frame:PlotFigure

import matplotlib

matplotlib.use(‘WX’)

from matplotlib.backends.backend_wx import Toolbar, FigureCanvasWx, FigureManager

from matplotlib.figure import Figure

from matplotlib.axes import Subplot

import matplotlib.numerix as numpy

from RandomArray import *

from wxPython.wx import *

def create(parent):

return PlotFigure(parent)

[wxID_PLOTFIGURE] = map(lambda _init_ctrls: wxNewId(), range(1))

class PlotFigure(wxFrame):

def _init_ctrls(self, prnt):

    # generated method, don't edit

    wxFrame.__init__(self, id=wxID_PLOTFIGURE, name='Output', parent=prnt,

          pos=wxPoint(480, 335), size=wxSize(640, 480),

          style=wxDEFAULT_FRAME_STYLE, title='Results')

    self.SetClientSize(wxSize(1280, 893))

def __init__(self, parent):

    self._init_ctrls(parent)

    self.fig = Figure((10,8), 75)

    self.canvas = FigureCanvasWx(self,-1, self.fig)

    self.toolbar = Toolbar(self.canvas)

    self.toolbar.Realize()

	# On Windows, default frame size behaviour is incorrect

    # you don't need this under Linux

    tw, th = self.toolbar.GetSizeTuple()

    fw, fh = self.canvas.GetSizeTuple()

    self.toolbar.SetSize(wxSize(fw, th))

   

    # Create a figure manager to manage things

    self.figmgr = FigureManager(self.canvas, 1, self)

   

    # Now put all into a sizer

    sizer = wxBoxSizer(wxVERTICAL)

	# This way of adding to sizer prevents resizing

    #sizer.Add(self.fig, 0, wxLEFT|wxTOP)

	# This way of adding to sizer allows resizing

    sizer.Add(self.fig, 1, wxLEFT|wxTOP|wxGROW)

	# Best to allow the toolbar to resize!

    sizer.Add(self.toolbar, 0, wxGROW)

    self.SetSizer(sizer)

    self.Fit()

   

def plot_data(self, x,y):

    """

    This function will plot the time series as output by odeint.

    """

    # Use this line if using a toolbar

    a = self.figmgr.add_subplot(111)

   

    # Or this one if there is no toolbar

    #a = Subplot(self.fig, 111)

   

    nvar = min(y[0].shape)

   

    for i in range(nvar):

        a.plot (x,y[0][:,i])

    #plot (x,timeseries[1])

    a.set_xlabel('Time')

    a.set_ylabel('Y[i]')

    a.set_title('Time series')

#—generating tuple of legends-------------------------------------------------

    b = range(nvar)

    leg = tuple(['y['+str(i)+']' for i in b])

#-------------------------------------------------------------------------------

    a.legend(leg)

   

    self.toolbar.update()

def plotStats(self,x, ts):

    """

    This function will plot prior an posteriors for the model variables and parameters.

    """

    # Use this line if using a toolbar

    a = self.figmgr.add_subplot(111)

   

    # Or this one if there is no toolbar

    #a = Subplot(self.fig, 111)

   

   

    a.plot(x,ts[0], 'r-o',x,ts[1],'b-.', x,ts[2],'b-.')

   

   

def plotDist(data,vname):

    """

    Plots histograms ofthe prior and posterior distributions of the model components

    meldOut is the output of the Melding.SIR function: (w,qtiltheta,qtilphi,q1est)

    """

    # Use this line if using a toolbar

    a = self.figmgr.add_subplot(111)

   

    # Or this one if there is no toolbar

    #a = Subplot(self.fig, 111)

   

    nb, bins, patches = a.hist(data, normed=1)

    a.set_title('Prior Distribution')

    a.set_xtitle(vname)

   

    nvp = len(priors) # Get number of variable + parameters in the model)

    nlik = len (liks) # Get number of likelihood functions

   

    for i in range(nvp):

        nb, bins, patches = a.hist(priors[i], normed=1)

        if i > 0:

            a.figure(i+1)

        a.set_title('Prior Distribution')



       

   

   

def GetToolBar(self):

    # You will need to override GetToolBar if you are using an

    # unmanaged toolbar in your frame

    return self.toolbar

if name == ‘main’:

app = wxPySimpleApp()

frame = create(None)

x = normal(0,1,50)

y = normal(0,1,(5,50))

frame.plot_data(x,y)

frame.Show()

app.MainLoop()