Autoscale in pylab-interface

Hi everyone

When looking at the little code example below
it can be seen see that you have to mix programming
paradigms to disable autoscaling:

    figure(1)
    ax = subplot(111)
    axis((-0.25,2.0,0.0,1.3))
    axis('scaled')
    ax.set_autoscale_on(False)

Wouldn't another 'axis' option make the
whole thing more consistent?

    figure(1)
    axis((-0.25,2.0,0.0,1.3))
    axis('scaled')
    axis(autoscale=False)

Best regards,
Nikolai

···

--
"1984" is not a howto!

Nikolai Hlubek wrote:

Wouldn't another 'axis' option make the
whole thing more consistent?

<soapbox>

Using the OO interface everywhere would make the whole thing more consistent:

fig = pylab.figure(1)
ax = fig.add_subplot(111)
ax.set_xlim(-0.25,2.0)
ax.set_ylim(0.0,1.3)
ax.set_aspect('scaled', True)
ax.set_autoscale_on(False)
ax.plot((0,.2,.3,.4,1.5), (0,.5,.3,.92,.48))

<\soapbox>

-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...

Christopher Barker wrote:

Nikolai Hlubek wrote:

Wouldn't another 'axis' option make the
whole thing more consistent?

<soapbox>

Using the OO interface everywhere would make the whole thing more
consistent:

fig = pylab.figure(1)
ax = fig.add_subplot(111)
ax.set_xlim(-0.25,2.0)
ax.set_ylim(0.0,1.3)
ax.set_aspect('scaled', True)
ax.set_autoscale_on(False)
ax.plot((0,.2,.3,.4,1.5), (0,.5,.3,.92,.48))

<\soapbox>

flame(on) :wink:

If a procedural interface is provided whats wrong with using it?

And besides, who uses an interface which reminds of disposal of bodily
wastes? :wink:

flame(off)

Nikolai

···

--
"1984" is not a howto!

Nikolai Hlubek wrote:

Christopher Barker wrote:

Using the OO interface everywhere would make the whole thing more
consistent:

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
wastes? :wink:

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):

name spaces
OO

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:

import OOlab

fig = OOlab.figure(1)
ax = fig.subplot(111)

ax.limits = (-0.25, 2.0, 0.0, 1.3)
ax.aspect = 'scaled'
ax.autoscale = False
ax.plot((0,.2,.3,.4,1.5), (0,.5,.3,.92,.48))

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,
                        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!

-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...

Hi,

I agree with you that it'll be better to use only pythonic stuff instead matlab but there are a lack of information to do it. It's sometimes difficult to find any informatin to use correctly matplotlib with an OO approach especially when you don't know very well python and the OO programmation.

N.

Christopher Barker wrote:

···

Nikolai Hlubek wrote:

Christopher Barker wrote:

Using the OO interface everywhere would make the whole thing more
consistent:

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
wastes? :wink:

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):

name spaces
OO

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:

import OOlab

fig = OOlab.figure(1)
ax = fig.subplot(111)

ax.limits = (-0.25, 2.0, 0.0, 1.3)
ax.aspect = 'scaled'
ax.autoscale = False
ax.plot((0,.2,.3,.4,1.5), (0,.5,.3,.92,.48))

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,
                       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!

-Chris