On Sun, Mar 21, 2010 at 2:30 PM, Eric Firing <efir...@hawaii.edu> wrote:
> Is the added complexity, scrambling pylab into the OO layer, and need for
> explanation, really worth the gain? As far as I can see, it merely adds
one
> more way to do something--and not a particularly recommended way. It is
no
> more concise than using sca(). It may be slightly more readable because
of
> the indentation, but that is the only advantage I see.
>
* complexity
I guess the code below is a "minimal" implementation (it worked okay with
my limited tests).
# context manager
def __enter__(self):
import matplotlib.pyplot as plt
plt.sca(self)
return self
def __exit__(self, type, value, tb):
pass
* readability
1) with "with" statement
fig, axarr = subplots(2,2)
> for ax1, ax2 in axarr:
with ax1:
plot([1,2,3])
> with ax2:
plot([2,3,4])
2) with "sca"
> fig, axarr = subplots(2,2)
> for ax1, ax2 in axarr:
sca(ax1)
plot([1,2,3])
> sca(ax2)
plot([2,3,4])
While I certainly prefer 1) over 2) as far as the readability is concerned,
I currently don't have a strong opinion whether the readability beats the
complexity in this case.
So, unless there are more of positive feedbacks from others, I'll consider
it dropped.
Regards,
-JJ
------------------------------------------------------------------------------
Download Intel® 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