On Wed, Jan 21, 2009 at 8:31 PM, Adam Mercer <ramer...@gmail.com> wrote:
> Anyone?
>
> Cheers
>
> Adam
>
> On Sat, Jan 17, 2009 at 17:19, Adam Mercer <ramer...@gmail.com> wrote:
>> Hi
>>
>> I'm trying to track down an issue with the CocoaAgg backend on Mac OS
>> X using MacPorts, when run with the CocoaAgg backend the following
>> code:
>>
>> from pylab import *
>> import time
>>
>> ion()
>>
>> tstart = time.time()
>> x = arange(0,2*pi,0.01)
>> line, = plot(x,sin(x))
>> for i in arange(1,200):
>>    line.set_ydata(sin(x+i/10.0))
>>    draw()
>>
>> print 'FPS:' , 200/(time.time()-tstart)
>>
>> fails with the backtrace:
>>
>> $ python temp.py -dCocoaAgg
>> Traceback (most recent call last):
>>  File "temp.py", line 2, in <module>
>>    from pylab import *
>>  File "/opt/local/lib/python2.5/site-packages/pylab.py", line 1, in <module>
>>    from matplotlib.pylab import *
>>  File "/opt/local/lib/python2.5/site-packages/matplotlib/pylab.py",
>> line 253, in <module>
>>    from matplotlib.pyplot import *
>>  File "/opt/local/lib/python2.5/site-packages/matplotlib/pyplot.py",
>> line 75, in <module>
>>    new_figure_manager, draw_if_interactive, show = pylab_setup()
>>  File 
>> "/opt/local/lib/python2.5/site-packages/matplotlib/backends/__init__.py",
>> line 25, in pylab_setup
>>    globals(),locals(),[backend_name])
>>  File 
>> "/opt/local/lib/python2.5/site-packages/matplotlib/backends/backend_cocoaagg.py",
>> line 54, in <module>
>>    class FigureCanvasCocoaAgg(FigureCanvasAgg):
>>  File 
>> "/opt/local/lib/python2.5/site-packages/matplotlib/backends/backend_cocoaagg.py",
>> line 63, in FigureCanvasCocoaAgg
>>    start_event_loop.__doc__=FigureCanvasBase.start_event_loop_default.__doc__
>> NameError: name 'FigureCanvasBase' is not defined\

This looks like a simple bug in which FigureCanvasBase is not
imported.  Try replacing line 31 in
matplotlib/backends/backend_cocoaagg.py with this::

    from matplotlib.backend_bases import FigureManagerBase, FigureCanvasBase

I've fixed the bug on the svn branch and trunk.

In a somewhat unrelated note, this style of "pylab animation" is no
longer encouraged or supported (and your example does not work with
cocoaagg, even with the fix, on my osx box).  Rather, you should use
the GUI timeout or idle loop for your backend to support animation, as
in the examples in
http://matplotlib.sourceforge.net/examples/animation/index.html.
While there are no cocoa specific examples (feel free to contribute
one) the pattern should be fairly clear across the UIs we have
examples for.

JDH

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to