Evolution of the interface

Hello,

I really appreciate the work done by matplotlib but I really think that

the interface must evolve. Here is a small example.

object.set_something(…)

object.get_something()

It could be easier to use a jQuery like style as in the following lines.

object(…)

object()

This will considerably simplify things.

Here is a more realistic example.

fig = pylab.figure()

ax = fig.add_subplot(1,1,1)

ax.set_xlabel(“xLabel”)

ax.set_ylabel(“yLabel”)

The a jQuery like style would be as in the following lines.

fig = pylab.figure()

ax = fig.add_subplot(1,1,1)

ax(xlabel = “xLabel”, ylabel = “yLabel”)

I don’t know enough matplotlib to propose other examples

but I really think that there is a lot of things that could make

matplotlib much more Pythonicly easy to use.

Christophe BAL

Interesting thoughts, Christophe. There is currently a MEP to do something
similar:
https://github.com/matplotlib/matplotlib/wiki/MEP13

···

On Fri, Mar 15, 2013 at 8:01 AM, Christophe BAL <projetmbc@...287...> wrote:

Hello,
I really appreciate the work done by matplotlib but I really think that
the interface must evolve. Here is a small example.

* object.set_something(...)*
* object.get_something()*

It could be easier to use a jQuery like style as in the following lines.

* object(...)*
* object()*

This will considerably simplify things.

Here is a more realistic example.

* fig = pylab.figure()*
* ax = fig.add_subplot(1,1,1)*
*
*
* ax.set_xlabel(*"xLabel"*)*
* ax.set_ylabel(*"yLabel"*)*

The a jQuery like style would be as in the following lines.

* fig = pylab.figure()*
* ax = fig.add_subplot(1,1,1)*
*
*
* ax(xlabel = *"xLabel"*, ylabel = *"yLabel"*)*
*
*
I don't know enough matplotlib to propose other examples
but I really think that there is a lot of things that could make
matplotlib much more Pythonicly easy to use.

I don’t personally like this approach. Python has very clear separation between the initialization of methods, which acts like a function that returns an instance, and the modification of existing instances, which uses attributes. This syntax muddies the distinction, having something that should behave like an instance instead behaving as a function.

Is there any precedence for using this sort of syntax in python? I have not seen it anywhere else. You mention jQuery, but that is JavaScript not python. As far as I have seen

···

On Mar 15, 2013 4:01 PM, “Christophe BAL” <projetmbc@…287…> wrote:

Hello,
I really appreciate the work done by matplotlib but I really think that
the interface must evolve. Here is a small example.

object.set_something(...)
object.get_something()

It could be easier to use a jQuery like style as in the following lines.

object(...)
object()

This will considerably simplify things.

Here is a more realistic example.

fig = pylab.figure()
ax  = fig.add_subplot(1,1,1)

ax.set_xlabel("xLabel")
ax.set_ylabel("yLabel")

The a jQuery like style would be as in the following lines.

fig = pylab.figure()
ax  = fig.add_subplot(1,1,1)

ax(xlabel = "xLabel", ylabel = "yLabel")

I don’t know enough matplotlib to propose other examples
but I really think that there is a lot of things that could make
matplotlib much more Pythonicly easy to use.

Christophe BAL

I am afraid I disagree a little bit. The call: object(…) [if
object is an instance, not a class, otherwise ths would be a
constructor] -

  • means object.call(…). Now, in principle one can throw inside a generic “call” plenty of
    attribute changes, but just imagine the parsing of all the possible
    argument combination. And, BTW, what would it mean: xxx= ax() ? In
    general case this is not practical.
    The methods in Python called.through.the.dot.notation are there to
    stay, I think.
    Jerzy Karczmarczuk
    Caen, France.
···

Christophe BAL:

  I really appreciate the work done by matplotlib but I

really think that
the interface must evolve. Here is a small example.

object.set_something(…)

object.get_something()

    It could be easier to use a jQuery like style as in the

following lines.

object(…)

object()

This will considerably simplify things.

Here is a more realistic example.

fig = pylab.figure()

ax = fig.add_subplot(1,1,1)

ax.set_xlabel(“xLabel”)

ax.set_ylabel(“yLabel”)

The a jQuery like style would be as in the following lines.

fig = pylab.figure()

ax = fig.add_subplot(1,1,1)

ax(xlabel = “xLabel”, ylabel = “yLabel”)

      I don't know enough

matplotlib to propose other examples

      but I

really think that **there is a lot **** of things
that could make **

** matplotlib
much more Pythonicly easy to use.**

Hello,
I really appreciate the work done by matplotlib but I really think that
the interface must evolve. Here is a small example.

object.set_something(...)
object.get_something()

It could be easier to use a jQuery like style as in the following lines.

object(...)
object()

This will considerably simplify things.

Here is a more realistic example.

fig = pylab.figure()
ax  = fig.add_subplot(1,1,1)

ax.set_xlabel("xLabel")
ax.set_ylabel("yLabel")

The a jQuery like style would be as in the following lines.

fig = pylab.figure()
ax  = fig.add_subplot(1,1,1)

ax(xlabel = "xLabel", ylabel = "yLabel")

Just fyi: you can always do

ax.set(xlabel=“something”, ylabel=“something”)

···

On Mar 15, 2013 10:01 AM, “Christophe BAL” <projetmbc@…287…> wrote:

I don’t know enough matplotlib to propose other examples
but I really think that there is a lot of things that could make
matplotlib much more Pythonicly easy to use.

Christophe BAL


Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar


Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

On 2013-03-15 08:19, Paul Hobson wrote:> On Fri, Mar 15, 2013 at 8:01 >
>> Hello,
>> I really appreciate the work done by matplotlib but I really think that
>> the interface must evolve. Here is a small example.
>>
>> * object.set_something(...)*
>> * object.get_something()*
>>
>> It could be easier to use a jQuery like style as in the following lines.
>>
>> * object(...)*
>> * object()*

> Interesting thoughts, Christophe. There is currently a MEP to do something
> similar:
> https://github.com/matplotlib/matplotlib/wiki/MEP13

  I think the current situation is better than this jQuery style, and the MEP is better than the current situation. Using lots of verbose getters and setters is unpythonic, but calling objects directly in that catch-all way is even more unpythonic. There are lots of things you might want to do to an MPL object, and we shouldn't elevate attribute get/set as the "main one" that should be accessed by the call syntax.

  That MEP would be great, though!

···

AM, Christophe BAL <projetmbc@...287...> wrote:

--
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail."
    --author unknown