From: matthew a. <ma...@ca...> - 2004-11-09 02:35:25
|
Thanks for matplotlib 0.64. Great to see steady improvements continue to roll in. First the good news. IPython (0.6.4) using pylab works for me again. It broke with 0.63 / 0.6.3 and gtk 2.4.x, complaining about gtk mainloop and gtk main in the middle of the IPython prompt and then freezing up. I had some minor issues with my GTK matplotlib API code. 1. I had to change toolbar = NavigationToolbar(canvas) to toolbar = NavigationToolbar(canvas, win) where win is the GTK window object. I guess the matplotlib API is still unstable. :) 2. I was getting errors that the matplotlib.backends.backend_mod.IMAGE_FORMAT attribute was not found, during toolbar initialization. I put in a workaround. works with matplotlib 0.63: import matplotlib matplotlib.use('GTK') from matplotlib.backends.backend_gtk import FigureCanvasGTK from matplotlib.backends.backend_ps import FigureCanvasPS from matplotlib.backends.backend_gtk import NavigationToolbar2GTK as NavigationToolbar using matplotlib 0.64: import matplotlib matplotlib.use('GTK') from matplotlib.backends import backend_gtk matplotlib.backends.backend_mod = backend_gtk from matplotlib.backends.backend_gtk import FigureCanvasGTK from matplotlib.backends.backend_ps import FigureCanvasPS from matplotlib.backends.backend_gtk import NavigationToolbar2GTK as NavigationToolbar This style was cribbed from matplotlib examples and / or emails on this list. Cheers, Matthew. |
From: John H. <jdh...@ac...> - 2004-11-09 16:14:15
|
>>>>> "matthew" == matthew arnison <ma...@ca...> writes: matthew> 1. I had to change toolbar = NavigationToolbar(canvas) matthew> to toolbar = NavigationToolbar(canvas, win) matthew> where win is the GTK window object. I guess the matthew> matplotlib API is still unstable. :) Oops. This one slipped under my radar screen. Sorry I didn't announce it as an API change. This also break examples/embedding_in_gtk2.py, for the same reason (fixed in CVS). Thanks for letting us know... JDH |
From: matthew a. <ma...@ca...> - 2004-11-16 06:45:50
|
Oh dear. I'm going to take another u-turn, and say I hit this IMAGE_FORMAT attribute glitch again. To atone for my reversals, I have isolated a test case, and I attach sample code. It seems to be triggered by importing matplotlib.matlab in one module, and importing matplotlib backend stuff directly in another module. Running frog.py gives: Traceback (most recent call last): File "frog.py", line 4, in ? embedding_in_gtk2_mra.plotme() File "M:\home\My Documents\My Downloads\matplotlib-0.64\matplotlib-0.64\examples\embedding_in_gtk2_mra.py", line 39, in plotme toolbar = NavigationToolbar(canvas, win) File "C:\Python23\lib\site-packages\matplotlib\backends\backend_gtk.py", line 963, in __init__ NavigationToolbar2.__init__(self, canvas) File "C:\Python23\Lib\site-packages\matplotlib\backend_bases.py", line 786, in __init__ self._init_toolbar() File "C:\Python23\lib\site-packages\matplotlib\backends\backend_gtk.py", line 1028, in _init_toolbar self._init_toolbar2_4() File "C:\Python23\lib\site-packages\matplotlib\backends\backend_gtk.py", line 1091, in _init_toolbar2_4 parent=self.win,) File "C:\Python23\lib\site-packages\matplotlib\backends\backend_gtk.py", line 1423, in __init__ self.IMAGE_FORMAT = matplotlib.backends.backend_mod.IMAGE_FORMAT AttributeError: 'module' object has no attribute 'IMAGE_FORMAT' As commented in the code, changing the order of the import statements in frog.py avoids the bug. Or using the workaround I mentioned below. Hmmm. Now I remember an email from John Hunter saying that pythonic matplotlib should not be mixed with the matlab interface. Maybe this glitch is an artefact of that. It does mean however that all my modules have to use one API or the other. Cheers, Matthew. matthew arnison wrote: > 2. I was getting errors that the > matplotlib.backends.backend_mod.IMAGE_FORMAT attribute was not found, > during toolbar initialization. I put in a workaround. > > works with matplotlib 0.63: > > import matplotlib > matplotlib.use('GTK') > > from matplotlib.backends.backend_gtk import FigureCanvasGTK > from matplotlib.backends.backend_ps import FigureCanvasPS > from matplotlib.backends.backend_gtk import NavigationToolbar2GTK as > NavigationToolbar > > using matplotlib 0.64: > > import matplotlib > matplotlib.use('GTK') > from matplotlib.backends import backend_gtk > matplotlib.backends.backend_mod = backend_gtk > > from matplotlib.backends.backend_gtk import FigureCanvasGTK > from matplotlib.backends.backend_ps import FigureCanvasPS > from matplotlib.backends.backend_gtk import NavigationToolbar2GTK as > NavigationToolbar > > This style was cribbed from matplotlib examples and / or emails on this > list. > > Cheers, > Matthew. |
From: John H. <jdh...@ac...> - 2004-11-16 14:45:53
|
>>>>> "matthew" == matthew arnison <ma...@ca...> writes: matthew> Oh dear. I'm going to take another u-turn, and say I hit matthew> this IMAGE_FORMAT attribute glitch again. Try running your script with --verbose-helpful or --verbose-debug and report the output. That way we can see what is happening behind the scenes. matthew> To atone for my reversals, I have isolated a test case, matthew> and I attach sample code. It seems to be triggered by matthew> importing matplotlib.matlab in one module, and importing matthew> matplotlib backend stuff directly in another module. matthew> Running frog.py gives: matthew> line 1423, in __init__ self.IMAGE_FORMAT = matthew> matplotlib.backends.backend_mod.IMAGE_FORMAT matthew> AttributeError: 'module' object has no attribute matthew> 'IMAGE_FORMAT' Fernando added the backend_mod to matplotlib.backends.__init__.py -- perhaps he has some insight into what is going on. matthew> As commented in the code, changing the order of the matthew> import statements in frog.py avoids the bug. Or using the matthew> workaround I mentioned below. matthew> Hmmm. Now I remember an email from John Hunter saying matthew> that pythonic matplotlib should not be mixed with the matthew> matlab interface. Maybe this glitch is an artefact of matthew> that. It does mean however that all my modules have to matthew> use one API or the other. Yes, this is basically undefined. When using the API, you control figure canvases, windows, backends, etc, independently. When you import matplotlib.matlab, it parses your rc file (or not finding it falls back on a default) and may try and load a different backend. Since IMAGE_FORMAT is only used in some backends, my guess is you are seeing a backend conflict. Running --verbose-helpful should give you a clue about which backends matplotlib is loading. Note there are scant few features in the matlab interface that you can't access directly from the API. There is no compelling reason to mix them, save laziness, and as you are finding, it doesn't really save you any time. If you want to use something from the matlab interface and aren't sure how to do it from the API, open up matlab.py and take a look at how that function does it. A large number if not the majority of matlab interface functions simply forward their calls on to the current axes. JDH |
From: matthew a. <ma...@ca...> - 2004-11-16 22:59:21
|
Thanks for your feedback. I ran it with --verbose-helpful, and indeed I got some helpful messages (see below). I'll have to remember that in future. You are right, one module is loading the TKAgg backend, and the other is loading the GTK backend. The reason I have this in my modules is that I have one module A which is intended to be very general purpose, but has a couple of hooks to do plots. Module A doesn't care which backend it uses, and at the moment it uses the matplotlib.matlab interface because that's what I knew when I wrote it. Module B is a more specific application, which was using matlab calls, but I found I had to convert it to use GTK and the matplotlib API because I call it from application C which has a GUI window using GTK and glade. Summary: module A: general purpose, matlab API, no hardcoded backend module B: more specialised, matplotlib API, GTK backend, explicit GTK window management app C: more specialised, no matplotlib or matlab, GTK & glade GUI, functions from modules A and B used in callback threads I don't really want to force module A to use GTK, because TKAgg (or whatever's in .matplotlibrc) is more likely to work for other users on other machines. So for the moment I can get by, if I import module A after module B. But maybe there is some nice way to do things that I'm missing. Perhaps I can convert module A to use the matplotlib API but still not specify the backend, and it will still work standalone and also start playing nicely with module B and app C. I'll have a play with it when I get some time. Here is the output from "python frog.py --verbose-helpful": $ python frog.py --verbose-debug matplotlib data path c:\Python23\share\matplotlib loaded rc file c:\Python23\share\matplotlib\.matplotlibrc matplotlib version 0.64 verbose.level debug interactive is False numerix Numeric 23.3 font search path ['c:\\Python23\\share\\matplotlib', '/usr/share/fonts/msttf'] loaded ttfcache file M:\home\mra\.ttffont.cache matplotlib data path c:\Python23\share\matplotlib loaded rc file c:\Python23\share\matplotlib\.matplotlibrc matplotlib version 0.64 verbose.level debug interactive is False backend TkAgg version 8.4 Could not load matplotlib icon: Couldn't recognize the image file format for file 'c:\Python23\share\matplotlib\matplotlib.svg' Traceback (most recent call last): File "frog.py", line 6, in ? embedding_in_gtk2_mra.plotme() File "M:\home\My Documents\My Downloads\matplotlib-0.64\matplotlib-0.64\exampl es\embedding_in_gtk2_mra.py", line 43, in plotme toolbar = NavigationToolbar(canvas, win) File "C:\Python23\lib\site-packages\matplotlib\backends\backend_gtk.py", line 963, in __init__ NavigationToolbar2.__init__(self, canvas) File "C:\Python23\Lib\site-packages\matplotlib\backend_bases.py", line 786, in __init__ self._init_toolbar() File "C:\Python23\lib\site-packages\matplotlib\backends\backend_gtk.py", line 1028, in _init_toolbar self._init_toolbar2_4() File "C:\Python23\lib\site-packages\matplotlib\backends\backend_gtk.py", line 1091, in _init_toolbar2_4 parent=self.win,) File "C:\Python23\lib\site-packages\matplotlib\backends\backend_gtk.py", line 1423, in __init__ self.IMAGE_FORMAT = matplotlib.backends.backend_mod.IMAGE_FORMAT AttributeError: 'module' object has no attribute 'IMAGE_FORMAT' Cheers, Matthew. John Hunter wrote: >>>>>>"matthew" == matthew arnison <ma...@ca...> writes: > > > matthew> Oh dear. I'm going to take another u-turn, and say I hit > matthew> this IMAGE_FORMAT attribute glitch again. > > Try running your script with --verbose-helpful or --verbose-debug and > report the output. That way we can see what is happening behind the > scenes. > > matthew> To atone for my reversals, I have isolated a test case, > matthew> and I attach sample code. It seems to be triggered by > matthew> importing matplotlib.matlab in one module, and importing > matthew> matplotlib backend stuff directly in another module. > > matthew> Running frog.py gives: > matthew> line 1423, in __init__ self.IMAGE_FORMAT = > matthew> matplotlib.backends.backend_mod.IMAGE_FORMAT > matthew> AttributeError: 'module' object has no attribute > matthew> 'IMAGE_FORMAT' > > Fernando added the backend_mod to matplotlib.backends.__init__.py -- > perhaps he has some insight into what is going on. > > matthew> As commented in the code, changing the order of the > matthew> import statements in frog.py avoids the bug. Or using the > matthew> workaround I mentioned below. > > matthew> Hmmm. Now I remember an email from John Hunter saying > matthew> that pythonic matplotlib should not be mixed with the > matthew> matlab interface. Maybe this glitch is an artefact of > matthew> that. It does mean however that all my modules have to > matthew> use one API or the other. > > Yes, this is basically undefined. When using the API, you control > figure canvases, windows, backends, etc, independently. When you > import matplotlib.matlab, it parses your rc file (or not finding it > falls back on a default) and may try and load a different backend. > Since IMAGE_FORMAT is only used in some backends, my guess is you are > seeing a backend conflict. Running --verbose-helpful should give you a > clue about which backends matplotlib is loading. > > Note there are scant few features in the matlab interface that you > can't access directly from the API. There is no compelling reason to > mix them, save laziness, and as you are finding, it doesn't really > save you any time. If you want to use something from the matlab > interface and aren't sure how to do it from the API, open up matlab.py > and take a look at how that function does it. A large number if not > the majority of matlab interface functions simply forward their calls > on to the current axes. > > JDH |
From: Steve C. <ste...@ya...> - 2004-11-18 10:56:10
|
On Tue, 2004-11-16 at 17:45 +1100, matthew arnison wrote: > Oh dear. I'm going to take another u-turn, and say I hit this > IMAGE_FORMAT attribute glitch again. > > To atone for my reversals, I have isolated a test case, and I attach > sample code. It seems to be triggered by importing matplotlib.matlab in > one module, and importing matplotlib backend stuff directly in another > module. > > Running frog.py gives: > > Traceback (most recent call last): ... > "C:\Python23\lib\site-packages\matplotlib\backends\backend_gtk.py", line > 1423, in __init__ > self.IMAGE_FORMAT = > matplotlib.backends.backend_mod.IMAGE_FORMAT > AttributeError: 'module' object has no attribute 'IMAGE_FORMAT' Its now fixed in CVS. backend_gtk now knows about all image formats and does not need to look at other backends to see what formats they support. Steve |
From: Gary <pa...@in...> - 2004-11-18 23:14:48
|
Returning after a time to my animation project. The first thing i did was to make sure anim_tk.py still runs. It didn't. A ghost figure window appears, and there is a long stall, then the message: elapsed 10.7956385487 Fatal Python error: PyEval_RestoreThread: NULL tstate This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. Is it me, or did something break? WinXP, matplotlib 0.64, recently installed by deleting the existing matplolib directory and installing using the windows installer. Examples installed from the latest zip. thanks, gary |
From: Steve C. <ste...@ya...> - 2004-11-19 03:22:19
|
On Thu, 2004-11-18 at 18:14 -0500, Gary wrote: > Returning after a time to my animation project. > > The first thing i did was to make sure anim_tk.py still runs. It > didn't. A ghost figure window appears, and there is a long stall, then > the message: > > elapsed 10.7956385487 > Fatal Python error: PyEval_RestoreThread: NULL tstate > > This application has requested the Runtime to terminate it in an unusual > way. > Please contact the application's support team for more information. > > Is it me, or did something break? > WinXP, matplotlib 0.64, recently installed by deleting the existing > matplolib directory and installing using the windows installer. > Examples installed from the latest zip. > > thanks, > gary Its working OK for me. Fedora 3 Linux, matplotlib 0.64, Python 2.3.4 Steve |
From: Gary <pa...@in...> - 2004-11-21 19:16:39
|
Steve Chaplin wrote: >On Thu, 2004-11-18 at 18:14 -0500, Gary wrote: > > >>Returning after a time to my animation project. >> >>The first thing i did was to make sure anim_tk.py still runs. It >>didn't. A ghost figure window appears, and there is a long stall, then >>the message: >> >>elapsed 10.7956385487 >>Fatal Python error: PyEval_RestoreThread: NULL tstate >> >>This application has requested the Runtime to terminate it in an unusual >>way. >>Please contact the application's support team for more information. >> >>Is it me, or did something break? >>WinXP, matplotlib 0.64, recently installed by deleting the existing >>matplolib directory and installing using the windows installer. >>Examples installed from the latest zip. >> >>thanks, >>gary >> >> >Its working OK for me. >Fedora 3 Linux, matplotlib 0.64, Python 2.3.4 > >Steve > > > Thanks ... so it's either me or WinXP. I gave it a try on my other WinXP machine. Same thing. No dice. Can someone confirm that anim_tk.py runs (or doesn't) on WinXP / matplotlib 0.64 ?? Thanks, gary |
From: John H. <jdh...@ac...> - 2004-11-22 00:46:43
|
>>>>> "Gary" == Gary <pa...@in...> writes: Gary> Thanks ... so it's either me or WinXP. I gave it a try on Gary> my other WinXP machine. Same thing. No dice. Gary> Can someone confirm that anim_tk.py runs (or doesn't) on Gary> WinXP / matplotlib 0.64 ?? I can't test this under windows XP right now (I can tomorrow). But how are you running your script (double clicknig, from a shell, from within an IDE? What does c:> python anim_tk.py --verbose-helpful report? I searched the matplotlib-users archives at http://sourceforge.net/mailarchive/forum.php?forum_id=33405 for PyEval_RestoreThread. This has cropped up a few times before on windows (including a September post from you also on anim_tk which did not appear to be resolved). My usual first guess when people get this message is that they are trying to run matplotlib from within a GUI IDE and are getting an IDE conflict, which is why I asked you to test from the command shell. Let me know the results of the tests above, because I'd like to track this one down. JDH |
From: Gary <pa...@in...> - 2004-11-22 18:12:03
|
John Hunter wrote: >>>>>>"Gary" == Gary <pa...@in...> writes: >>>>>> >>>>>> > > Gary> Thanks ... so it's either me or WinXP. I gave it a try on > Gary> my other WinXP machine. Same thing. No dice. > > Gary> Can someone confirm that anim_tk.py runs (or doesn't) on > Gary> WinXP / matplotlib 0.64 ?? > >I can't test this under windows XP right now (I can tomorrow). But >how are you running your script (double clicknig, from a shell, from >within an IDE? > >What does > > c:> python anim_tk.py --verbose-helpful report? > >I searched the matplotlib-users archives at >http://sourceforge.net/mailarchive/forum.php?forum_id=33405 for >PyEval_RestoreThread. This has cropped up a few times before on >windows (including a September post from you also on anim_tk which did >not appear to be resolved). > >My usual first guess when people get this message is that they are >trying to run matplotlib from within a GUI IDE and are getting an IDE >conflict, which is why I asked you to test from the command shell. >Let me know the results of the tests above, because I'd like to track >this one down. > >JDH > > > John, No IDE or double clicks. Straight from the command line. C:\Python23\Lib\site-packages\matplotlib\examples>python anim_tk.py --verbose-helpful matplotlib data path C:\PYTHON23\share\matplotlib loaded rc file C:\PYTHON23\share\matplotlib\.matplotlibrc matplotlib version 0.64 verbose.level helpful interactive is False numerix Numeric 23.0 font search path ['C:\\PYTHON23\\share\\matplotlib'] loaded ttfcache file C:\Documents and Settings\Gary\.ttffont.cache matplotlib data path C:\PYTHON23\share\matplotlib loaded rc file C:\PYTHON23\share\matplotlib\.matplotlibrc matplotlib version 0.64 verbose.level helpful interactive is False backend TkAgg version 8.4 elapsed 6.0779188952 Fatal Python error: PyEval_RestoreThread: NULL tstate This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. C:\Python23\Lib\site-packages\matplotlib\examples> |
From: John H. <jdh...@ac...> - 2004-11-22 18:49:36
|
>>>>> "Gary" == Gary <pa...@in...> writes: Gary> This application has requested the Runtime to terminate it Gary> in an unusual way. Please contact the application's support Gary> team for more information. Gary> C:\Python23\Lib\site-packages\matplotlib\examples> Hi Gary, the good news is that I could replicate the bug on XP and the better news is that I could fix it :-) It looks like a bug in the anim_tk script and not in matplotlib proper. Basically, anim_tk never calls the tk mainloop. Why this works under linux and not windows is not clear to me. The trick is to start the tk mainloop and use the tk after handler to run a command after x milliseconds. So I rewrote the example to do the animation in a loop, and used the after command to start this function after the mainloop is launched. If you have any additional trouble, you may want to try turning off tk.window_focus : False # Maintain shell focus for TkAgg in your rc file. Hope this helps! JDH #!/usr/bin/env python2.3 import matplotlib matplotlib.use('TkAgg') import matplotlib.matlab #import Tkinter as Tk import matplotlib.numerix as numerix fig = matplotlib.matlab.figure(1) ind = numerix.arange(60) x_tmp=[] for i in range(100): x_tmp.append(numerix.sin((ind+i)*numerix.pi/15.0)) X=numerix.array(x_tmp) lines = matplotlib.matlab.plot(X[:,0],'o') manager = matplotlib.matlab.get_current_fig_manager() def updatefig(*args): updatefig.count += 1 lines[0].set_ydata(X[:,updatefig.count%60]) manager.canvas.draw() return updatefig.count updatefig.count=-1 def run(*args): import time tstart = time.time() while 1: cnt = updatefig() if cnt==100: break print 'elapsed', 100.0/(time.time() - tstart) import Tkinter as Tk manager.window.after(10, run) manager.show() Tk.mainloop() |
From: Todd M. <jm...@st...> - 2004-11-22 19:01:45
|
On Mon, 2004-11-22 at 13:48, John Hunter wrote: > >>>>> "Gary" == Gary <pa...@in...> writes: > > Gary> This application has requested the Runtime to terminate it > Gary> in an unusual way. Please contact the application's support > Gary> team for more information. > > Gary> C:\Python23\Lib\site-packages\matplotlib\examples> > > Hi Gary, the good news is that I could replicate the bug on XP and the > better news is that I could fix it :-) I looked at this but couldn't solve it... way to go John! Cheers, Todd |