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 |