From: John Hunter <jdhunter@ac...>  20041011 13:33:58

>>>>> "JeanMichel" == JeanMichel Philippe <jeanmichel.philippe@...> writes: JeanMichel> Perfect! This is exactly what I needed for one of my JeanMichel> apps. Glad that worked for you. >> But if you really want full control with no magic globals, I >> suggest using the matplotlib API rather than the matlab >> interface. Here is a minimal example with the SVG backend to >> create a figure w/o the matlab interface JeanMichel> Well, what do you exactly mean by full control? The JeanMichel> fact that the figure is no more controlled by JeanMichel> matplotlib.matlab (as matlab does) but under my own JeanMichel> control? So that the application is now fully JeanMichel> responsible for displaying it? JeanMichel> NB: currently I'm targeting TkAgg. What I mean is that is that if you want to explicitly control when your figure windows are shown, you need to use the matplotlib API, and example of which for tkagg is at http://matplotlib.sf.net/examples/embedding_in_tk.py. In this case, you explicitly make the calls to show or hide your window when you want. If you use the matlab interface, you are constrained either to 1) if interactive is False, show all of your figures at the end of the script when you call show or 2) if interactive is True, show all your windows at the time of their creation. Actually, you may have a 3rd (untested, unsupported) option with the matlab interface. Thanks to the changes Fernando and I introduced to support ipython, I believe as of matplotlib 0.62 it is safe to call show repeatedly without blocking script execution. You may want to test this and report back. JeanMichel> I'm afraid I don't understand why this should remove JeanMichel> "magic" globals, I feel some globals are still JeanMichel> required... Some people do not like to use the matlab interface because it manages the current figure and axes for them, behind the scenes. Eg when you type plot(x,y), the plot command is sent to the current figure and axes, as in matlab, which are stored as "global" (actually module level) variables in matplotlib.matlab. In the matplotlib API, you have to explicitly instantiate the figure and axes, and direct your plotting, saving, etc commands to these instances, as in from matplotlib.numerix import arange, sin, pi from matplotlib.figure import Figure f = Figure(figsize=(5,4), dpi=100) a = f.add_subplot(111) t = arange(0.0,3.0,0.01) s = sin(2*pi*t) a.plot(t,s) In a complex, nested application or script, it is sometimes nice to have this extra degree of clarity. Hope this helps, JDH 