I ran the attached python program under Ubuntu and Windows2000 with
different results. I expect the results to be similar.

Running under Ubuntu works great, and as expected.

Running under Windows2000 does not work well. Specifically, it works for
awhile, but then stops working and opens a small window with title:
wxPython: stdout/stderr, with many messages ultimately ending with the
root issue - Cannot_Open_Resource, Could not open facefile, in
_get_agg_font at line 301 of backend_agg.py.

On Windows2000 it runs for about 1 minute, then stops working and starts
delivering this series of error messages.

On Ubuntu, I can run it all day with no problems.

It might be easiest if you simply run the program under Linux and under
Windows and see if you note the same difference.

To run the program, maximize to expose the buttons and slider. Press
Start - you should see the plot flip back-and-forth between sin and cos
every 1 second. Move the slider to adjust the speed of flip.

I know that this program could be laid out better, etc - and that is not
my issue; this program is just a quick check of the capabilities of
matplotlib plot updates. I am interested in supporting real-time
plotting using matplotlib within a wxPython GUI. So, maybe you could
suggest an alternative way to write this program that works well on
Windows.

[More fundamentally, this program should work equivalently on Windows
and Linux. This may be a wxWidgets issue however, i.e. perhaps it
involves how graphical resources are obtained/available/reclaimed from
the underlying graphics subsystem of the OS. Perhaps the reclaim is much
more efficient under Linux and I need to do some explicit resource
reclaim under Windows (?).]

BTW, if you are interested, I can clean this snippet up a little and
maybe you would want to include it in your examples, as it demonstrates
another aspect of matplotlib use that may be of general interest (?). Of
course, it should first also work under Windows :).

Thanks for any replies.
from numpy import arange, sin, cos, pi

import matplotlib

matplotlib.use('WXAgg')

from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas

from matplotlib.figure import Figure

import wx

app=None

t = arange(0.0,3.0,0.01)
s = sin(2*pi*t)
c = cos(2*pi*t)

class PlotFrame(wx.Frame):

    def __init__(self):
        wx.Frame.__init__(self,None,-1,'PlotFrame',size=(550,350))

        self.figure = Figure()
        
        self.axes = self.figure.add_subplot(111)
        self.axes.plot(t,s)
        self.axes.hold(False)

        pnl = wx.Panel(self, -1)
        self.canvas = FigureCanvas(pnl, -1, self.figure)
        self.canvas.draw()

        self.flag = 1
        self.timer = wx.Timer(self, 1)
        
        wx.Button(pnl, 2, 'Start', (250, 500))
        wx.Button(pnl, 3, 'Stop', (350, 500))
        self.sld = wx.Slider(pnl, 4, 1000, 10, 2000, (300, 600), (200, -1), 
		wx.SL_AUTOTICKS | wx.SL_HORIZONTAL | wx.SL_LABELS)

        wx.EVT_TIMER(self, 1, self.OnTimer)
        wx.EVT_BUTTON(self, 2, self.OnStart)
        wx.EVT_BUTTON(self, 3, self.OnStop)
        wx.EVT_SLIDER(self, 4, self.OnSlider)

        self.Show(True)
        self.Centre()

    def OnTimer(self, event):
        if self.flag == 1:
            self.axes.plot(t,c)
            self.flag = 0
        else:
            self.axes.plot(t,s)
            self.flag = 1
        self.canvas.draw()

    def OnStart(self, event):
        self.timer.Start(1000)

    def OnStop(self, event):
        self.timer.Stop()

    def OnSlider(self, event):
        val = self.sld.GetValue()
        self.timer.Stop()
        self.timer.Start(val)

app = wx.App()
PlotFrame()
app.MainLoop()
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to