Jae-Joon Lee wrote:
> 
> 
> On Sat, Mar 20, 2010 at 8:40 PM, Eric Firing <efir...@hawaii.edu 
> <mailto:efir...@hawaii.edu>> wrote:
> 
>         By the way, given that we now have "suplots" in the pyplot
>         namespace,
>         can we have sca also?
> 
> 
>     Done in svn 8205.
> 
> 
> 
> Eric,
> 
> A minor question. I wonder whether an explicit for-loop inside 
> pyplot.sca is necessary?
> Here is a slight variation w/o a for-loop (well, the for-loop is 
> implicitly done with the "in" operator I guess) that seems to work for 
> me, but I may be missing something.  
> 
>     managers = _pylab_helpers.Gcf.get_all_fig_managers()
>     if ax.figure.canvas.manager in managers and \
>            ax in ax.figure.axes:
>         _pylab_helpers.Gcf.set_active(ax.figure.canvas.manager)
>         ax.figure.sca(ax)
>         return
>     raise ValueError("Axes instance argument was not found in a figure.")
> 
> Regards,
> 
> -JJ
> 

JJ,

I think your version would need an additional try/except or conditional, 
because a Figure doesn't necessarily have a canvas assigned to it, and a 
canvas doesn't necessarily have a manager.  Granted, the problem would 
arise only under odd circumstances involving a mixture of pyplot and OO 
styles--and maybe there is actually something that would prevent the 
problem from arising at all--but I would want to be sure the problem 
either was handled, or could not arise.  So, I think my version ends up 
being simpler, safer, and easier to understand--at least for me.

Eric


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to