|
From: Humufr <hu...@ya...> - 2006-03-07 19:35:24
|
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? ;-)
>
> 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
>
>
>
|