Nikolai Hlubek wrote:
Christopher Barker wrote:
Using the OO interface everywhere would make the whole thing more
If a procedural interface is provided whats wrong with using it?
If you ask me, it never should have been provided! But the question here is: do we want to add more and more to pylab, until it replicates all the OO functionality -- I think not. But then, if we don't, then you get the situation you've encountered, having to occasionally drop into the OO interface to do more advanced things.
That's why I think encouraging people to use pylab is not such a great idea. I have an example of this taken to the extreme-- A colleague of mine wrote a bunch of fairly involved pylab-based code to create PNG plots. Later, he decided to put them into a wxPython app, but you can't use pylab embedded in wxPython, so he ended up creating the PNGs, then loading them into wxPython from disk. If he had just used the OO interface to begin with, he'd have had a very easy time adapting it to embedded use. (it's still not that hard, but there is a perceived big distinction)
And besides, who uses an interface which reminds of disposal of bodily
You do have a point there. Unfortunately, the pylab interface was designed with usability in mind, while the OO interface, less so. However, the reason I use python rather than matlab is that I like the language much better, and this means (among other things):
I've toyed with the idea of writing yet another interface to MPL that would be as pythonic (rather than Matlabish) as possible. Your example might look something like this:
fig = OOlab.figure(1)
ax = fig.subplot(111)
ax.limits = (-0.25, 2.0, 0.0, 1.3)
ax.aspect = 'scaled'
ax.autoscale = False
key here is using name spaces and properties....
However, John's version is pretty nice too:
fig = pylab.figure(1)
ax = fig.add_subplot(111,
aspect=('scaled', True), autoscale_on=False)
keyword arguments are very pythonic!
Christopher Barker, Ph.D.
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception