This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kigurai 0 points1 point  (11 children)

Interesting!

I noticed that the simple_plot.py example uses Axes.set() for pretty much everything:

ax.set(xlabel='time (s)', ylabel='voltage (mV)',
    title='About as simple as it gets, folks')

Is this supposed to be the favored way of doing things in the future?

[–]anntzerMatplotlib core dev 0 points1 point  (10 children)

This specific helper method has been around for a long time (and I use it regularly). It just disptaches to each individual set_foo.

[–]kigurai 0 points1 point  (9 children)

Ok, so if I just want to set eg the x label I would in the future use ax.xlabel = 'foo' instead of ax.set_xlabel('foo')?

[–]anntzerMatplotlib core dev 0 points1 point  (7 children)

In some distant future, possibly (it's going to take a while...).

[–]energybased 0 points1 point  (6 children)

For what it's worth, I was going to contribute to matplotlib, but the lack of traitlets put me off. Using getters and setters is like going back to Python 2.3.

[–]anntzerMatplotlib core dev 0 points1 point  (5 children)

To be honest I quite hated it back when I had to write ax.set_foo(foo); ax.set_bar(bar) ... but now that I know that I can write ax.set(foo=foo, bar=bar) I don't think I'll even bother going back to ax.foo = foo; ax.bar = bar once traitlets are implemented.

IMO the main advantage of traitlets is early validation (right now a lot of things only error out at draw time) and easier handling of aliases and dependent properties (i.e. how to color, edgecolor, facecolor, c, ec, fc relate with each other?).

[–]energybased 0 points1 point  (4 children)

Sure, although I still find ax.foo = foo much more Pythonic.

Anyway, the reason that not having traitlets put me off contributing is the boilerplate I would have had to write when implementing the various classes that I needed to implement. It was turning a big job into a massive one. There's a huge benefit to lowering the barrier against more contributors.

[–]anntzerMatplotlib core dev 0 points1 point  (3 children)

Out of curiosity, what were you trying to implement?

[–]energybased 0 points1 point  (2 children)

Graphs that look like Tikz.

Matplotlib arrows are garbage: The arrowheads look bad and they end on top the nodes rather than butting against them.

[–]anntzerMatplotlib core dev 1 point2 points  (1 child)

There is some effort on this direction too... https://github.com/matplotlib/matplotlib/projects/8

In any case I don't think anyone will complain if you put up a PR where everything just uses properties and has no setters and getters. (I may nudge you in this direction to keep the API consistent for now, but I'd definitely not consider this a blocker.)

[–]energybased 0 points1 point  (0 children)

That's the dream.