<p dir="ltr">I have done similar things (hiding groups of artists) using the tool manager and custom build tools.</p>
<p dir="ltr">In general I just use the gid property of each artist to keep track of different groups and on trigger I hide a specific group.</p>
<p dir="ltr">Also I use it to pop-up an artist-styler to change colors, linestyle etc...</p>
<p dir="ltr">It is indirect but allows to perform operations without touching base classes.</p>
<p dir="ltr">I know this is not what you asked but hope it helps</p>
<p dir="ltr">Federico</p>
<div class="gmail_quote">On Jun 5, 2016 10:38 PM, "Daniel McNeela" <<a href="mailto:daniel.mcneela@gmail.com">daniel.mcneela@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Basically I'm adding a "layer" construct to the Axes model that allows users to define groups of Matplotlib artists that can be manipulated, hidden, displayed, styled, etc. in tandem without affecting those artists which are on other layers. It's sort of analogous to the way in which layers work in Photoshop.<div><br></div><div>The issue with simply subclassing the Matplotlib Axes is that I want my subclass to fully integrate with pyplot and other modules. For example, if a user has my module imported and runs</div><div><br></div><div>>>> fig = plt.figure()</div><div>>>> subplot = plt.subplot(111)</div><div><br></div><div>I'd like for subplot to be an instance of my subclassed Axes rather than of the default one provided by Matplotlib.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jun 5, 2016 at 5:31 PM, Thomas Caswell <span dir="ltr"><<a href="mailto:tcaswell@gmail.com" target="_blank">tcaswell@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Simply sub-classing any of those classes in your code would reasonable.<div><br></div><div>I am curious about what sort of extensions you are adding?  I think in many cases writing functions that take in `Axes` (or `Figure` if that is the right scope) objects and operate on them.</div><div><br></div><div>An example of a project that is sub-classing `Axes` is <a href="https://github.com/scls19fr/windrose" target="_blank">https://github.com/scls19fr/windrose</a> .</div><div><br></div><div>Tom</div></div><br><div class="gmail_quote"><div><div><div dir="ltr">On Sun, Jun 5, 2016 at 5:16 PM Daniel McNeela <<a href="mailto:daniel.mcneela@gmail.com" target="_blank">daniel.mcneela@gmail.com</a>> wrote:<br></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr">Hi All,<div><br></div><div>I'm currently developing a Python package built on top of Matplotlib, and I'd like to add custom functionality to the Axes class while still retaining all of the default Matplotlib syntax and commands. To do this, I'd like to subclass matplotlib.axes.Axes (or possibly matplotlib.axes._base._AxesBase) and add additional class attributes and methods. Ideally, I'd like to do this without forking Matplotlib and directly editing the source so as to maintain compatibility with future Matplotlib releases. I see that in pyplot.py, calls to figure() accept an optional FigureClass argument which I could use to pass a custom subclass of Figure. I was thinking I could subclass Figure such that the subclass overrides methods such as Figure.add_subplot() by calling the superclass's method and passing my custom Axes subclass in as an optional argument. But I'm not sure which methods I'd have to override, or how deep the rabbit hole goes, as Axes objects seem to be generated in a number of places throughout the Matplotlib source.</div><div><br></div><div>If anyone who is familiar with the code base might be able to suggest a simple way in which I could accomplish this desired behavior, I would greatly appreciate it! Right now, I'm adding the desired functionality via a function that accepts Matplotlib Axes instances and binds custom attributes/methods to these instances via Python's type.MethodType, but this seems like a rather clunky and un-Pythonic approach to building what will likely be an extensive application.</div><div><br></div><div>Thank you in advance for your help!</div><div><br></div><div>Best,</div><div><br></div><div>Daniel McNeela</div></div></div></div>
_______________________________________________<br>
Matplotlib-devel mailing list<br>
<a href="mailto:Matplotlib-devel@python.org" target="_blank">Matplotlib-devel@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/matplotlib-devel" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-devel</a><br>
</blockquote></div>
</blockquote></div><br></div>
<br>_______________________________________________<br>
Matplotlib-devel mailing list<br>
<a href="mailto:Matplotlib-devel@python.org">Matplotlib-devel@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/matplotlib-devel" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-devel</a><br>
<br></blockquote></div>