Autoscale in pylab-interface

However, John's version is pretty nice too:

    > fig = pylab.figure(1) ax = fig.add_subplot(111,
    > xlim=(-0.25,2.0), ylim=(0.0,1.3), aspect=('scaled',
    > True), autoscale_on=False) ax.plot((0,.2,.3,.4,1.5),
    > (0,.5,.3,.92,.48))

    > keyword arguments are very pythonic!

The downside of having to use kwargs like this is that you have to
know about them in advance.

We could support

  ax.xlim = 0,1

Simply by defining the appropriate __getattr__ and __setattr__
functions with the existing code base in just a few lines of code.
There would be a couple of cases where we might see some name clashes
but there wouldn't be many, and we could easily fix these and
deprecate the old usage.

If you want to take a stab at this, I think it would be preferable
to writing "another interface". Better to improve the OO interface we
have....

The heavy reliance on setters and getters dates to the fact that I was
a C++ programmer before I was a python programmer, and I wrote
matplotlib fairly early into my diving into python. I started writing
it around python2.1 and python properties were not yet part of the
language. So historically that is why we have our own hacked up
version of properties based on these setters and getters. Since there
is a lot of code built around them at this point (particularly for
those doing a lot of OO matplotlib including yours truly) I am
hesitant to completely break it.

We have talked many times about doing something different, namely we
came very close to using enthought traits at one point, but hesitated
to pull the final trigger because they hadn't publicly released it and
there was no public user base so we weren't sure what the support
would be going forward. There has now been a public release but as
far as I know no widespread community adoption yet.

My inclination at this point is to take the path of least resistance
and simply make properties out of the existing setters and getters. I
think we could use python properties for this or do our own
getattr/setattr magic. I would also be amenable to using traits.

JDH

John Hunter wrote:

The downside of having to use kwargs like this is that you have to
know about them in advance.

Quite true.

We could support

  ax.xlim = 0,1

Simply by defining the appropriate __getattr__ and __setattr__
functions with the existing code base in just a few lines of code.

If you want to take a stab at this, I think it would be preferable
to writing "another interface". Better to improve the OO interface we
have....

I totally agree. The few things that might be nice would be some of pylab's figure, etc. management, with an OO style, but at the moment, I'm not even sure what those would be. I guess I need to wait until I find I need something, and then worry about it.

My goal had been to write another interface, with the idea that, if you liked it, it could get rolled into the main code, but as you seem to be interested, there's no reason not to just start rolling it in now.

The heavy reliance on setters and getters dates to the fact that I was
a C++ programmer before I was a python programmer

I suspected as much :wink:

Indeed, I've used a fair number of set_this() methods myself, even though Python is my first OO language. I'm changing my style more after reading "Python is not Java"

Since there
is a lot of code built around them at this point (particularly for
those doing a lot of OO matplotlib including yours truly) I am
hesitant to completely break it.

Of course. A major refactor is not the least bit necessary.

My inclination at this point is to take the path of least resistance
and simply make properties out of the existing setters and getters.

That sounds good to me. I'm still unclear on what traits buys you. maybe I need to look at it again.

think we could use python properties for this or do our own
getattr/setattr magic.

I'd just go with properties -- that's what they are for, and it would take very little code.

At some point I need to just shut up and write some code (and some docs). But there are so many things I want to do!

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
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

Chris.Barker@...259...