This is an idea that's been kicking around in my head for awhile.
Basically, the Axes class is way too expansive. Nelle made a major step in
the right direction with a PR that split it up into plotting and
non-plotting methods:
https://github.com/matplotlib/matplotlib/pull/1931/files
What I'd like to see is something that further separates plotting methods
into many smaller sub-modules/-packages. Organizing the code this way would
make it easier (for me at least) to read, understand, and make changes to
the code.
I think that this could be done in an API-compatible way. In fact, a few of
the plotting methods are already implemented this way: In other words, the
bulk of the methods are implemented as functions outside of Axes, and the
Axes methods that are just thin wrappers around those functions (or
classes). See, for example, `streamplot`, `barbs`, and `quiver` methods
The examples mentioned above simply take the axes as the first parameter.
Here's the Axes-method definition of `quiver`, for example:
def quiver(self, *args, **kw):
...
q = mquiver.Quiver(self, *args, **kw)
...
return q
(might be a good idea to add a decorator to maintain the function signature
and docstring)
This should work for any of the plotting methods (I would imagine). Another
alternative is for all these plotting functions to have an `ax` (or some
other spelling) keyword argument that defaults to None and then have a line
in every function that does something like
ax = ax if ax is not None else plt.gca()
If I'm not mistaken, this would allow pyplot functions to be even thinner
wrappers around these newly extracted functions. (In some cases, it might
just be a simple import from the the new sub-package/-module into the
`pyplot` namespace).
I haven't sat down and thought through all the details of such a change,
but I wanted to throw it out there to see if anything sticks.
Cheers,
-Tony
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel