<div dir="ltr">Thank you OceanWolf and Federico. I was previously unaware of the gid property of Artists and the new ToolManager classes, and it looks like what I have been doing is pretty similar to what is contained therein. You can take a look at my progress here: <div><br></div><div><a href="https://github.com/mcneela/Retina/tree/master/retina" target="_blank">https://github.com/mcneela/Retina/tree/master/retina</a></div><div><br></div><div>(The code is a bit messy as I haven't gotten around to cleaning it up yet.)</div><div><br></div><div>Basically I just have a layer dictionary associated with each axes in which I can update, set, and delete properties. If you interactively run the two examples included in that folder, you can type in commands at the Python interpreter and watch the plots change in response. For example, with the basic_layer_demo, you could run the following</div><div><br></div><div style="font-size:12.8px">>>> subplots.hide("cubic") # Hides the 'cubic' layer while keeping the 'quadratic' layer displayed</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">>>> subplots.show("cubic") # Redisplays the "cubic" layer</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">>>> subplots.set_style("cubic", 'ro') # Changes the style of the cubic layer</div><div style="font-size:12.8px">>>> subplots.build_layers() # Rebuilds the layers so that the new styling takes effect</div><div style="font-size:12.8px"><br></div><div>Is this something that you think would have utility if directly incorporated into Matplotlib's axes class, or is better to just have it built out on top as is done with the ToolManager classes?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 6, 2016 at 5:34 AM, OceanWolf <span dir="ltr"><<a href="mailto:juichenieder-nabb@yahoo.co.uk" target="_blank">juichenieder-nabb@yahoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="color:#000;background-color:#fff;font-family:Helvetica Neue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica,Arial,Lucida Grande,Sans-Serif;font-size:16px"><div dir="ltr">Hi Daniel,</div><div dir="ltr">I like your ideas. As Fedrico said, the group part has already exists, see <a href="http://matplotlib.org/examples/user_interfaces/toolmanager.html" target="_blank">http://matplotlib.org/examples/user_interfaces/toolmanager.html</a> for an example of this, the toolmanager part we still consider as experimental until at least 2.1 when we hope to have gotten it working with all backends together with <a href="http://matplotlib.org/devel/MEP/MEP27.html" target="_blank">http://matplotlib.org/devel/MEP/MEP27.html</a>, refactoring the FigureManager so as to decouple pyplot from the backends, a project that I have been working on.</div><div dir="ltr"><br></div><div dir="ltr">The other parts, <a href="http://matplotlib.org/devel/MEP/MEP26.html" target="_blank">http://matplotlib.org/devel/MEP/MEP26.html</a> which looks at creating Cascading Artist Style Sheets, based upon the CSS language spec for websites. I don't think anyone has started working on this, and may need some more definition and working out; then I started creating another MEP to figure out how to refactor the Axes and related classes into a more coherent and readably understandable structure, you can see the limited progress i have made at defining the document here... <a href="https://github.com/matplotlib/matplotlib/pull/5029" target="_blank">https://github.com/matplotlib/matplotlib/pull/5029</a> I have a few more ideas I want to put into this, just needing to find time to get back to it, probably once we have the backend refactor finished.</div><div dir="ltr"><br></div><div dir="ltr">Of course, matplotlib works as a fully opensource project, fully collaborative, so any source code changes you would like to see, make them in a fork, and PR them back to the matplotlib (or as I got started, forking Federico's toolmanager fork, and PRing back to him and his PR before merging into master, as part of MEP22). And of course, feel free to get involved in any of this stuff if you like it, the more the merrier :).</div><div dir="ltr"><br></div><div dir="ltr">Best,</div><div dir="ltr">OceanWolf<br></div><div><br></div><div style="display:block"> <div style="font-family:Helvetica Neue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica,Arial,Lucida Grande,Sans-Serif;font-size:16px"> <div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,Sans-Serif;font-size:16px"> <div dir="ltr"> <font face="Arial" size="2"> <hr size="1"> <b><span style="font-weight:bold">From:</span></b> Federico Ariza <<a href="mailto:ariza.federico@gmail.com" target="_blank">ariza.federico@gmail.com</a>><br> <b><span style="font-weight:bold">To:</span></b> Daniel McNeela <<a href="mailto:daniel.mcneela@gmail.com" target="_blank">daniel.mcneela@gmail.com</a>> <br><b><span style="font-weight:bold">Cc:</span></b> matplotlib development list <<a href="mailto:matplotlib-devel@python.org" target="_blank">matplotlib-devel@python.org</a>><br> <b><span style="font-weight:bold">Sent:</span></b> Monday, 6 June 2016, 12:19<span class=""><br> <b><span style="font-weight:bold">Subject:</span></b> Re: [Matplotlib-devel] (no subject)<br> </span></font> </div><div><div class="h5"> <div><br><div><div><div dir="ltr">I have done similar things (hiding groups of artists) using the tool manager and custom build tools.</div>
<div 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.</div>
<div dir="ltr">Also I use it to pop-up an artist-styler to change colors, linestyle etc...</div>
<div dir="ltr">It is indirect but allows to perform operations without touching base classes.</div>
<div dir="ltr">I know this is not what you asked but hope it helps</div>
<div dir="ltr">Federico</div>
<div><div>On Jun 5, 2016 10:38 PM, "Daniel McNeela" <<a rel="nofollow" shape="rect" href="mailto:daniel.mcneela@gmail.com" target="_blank">daniel.mcneela@gmail.com</a>> wrote:<br clear="none"><blockquote 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 clear="none"></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 clear="none"></div><div>>>> fig = plt.figure()</div><div>>>> subplot = plt.subplot(111)</div><div><br clear="none"></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><br clear="none"><div>On Sun, Jun 5, 2016 at 5:31 PM, Thomas Caswell <span dir="ltr"><<a rel="nofollow" shape="rect" href="mailto:tcaswell@gmail.com" target="_blank">tcaswell@gmail.com</a>></span> wrote:<br clear="none"><blockquote 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 clear="none"></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 clear="none"></div><div>An example of a project that is sub-classing `Axes` is <a rel="nofollow" shape="rect" href="https://github.com/scls19fr/windrose" target="_blank">https://github.com/scls19fr/windrose</a> .</div><div><br clear="none"></div><div>Tom</div></div><br clear="none"><div><div><div><div dir="ltr">On Sun, Jun 5, 2016 at 5:16 PM Daniel McNeela <<a rel="nofollow" shape="rect" href="mailto:daniel.mcneela@gmail.com" target="_blank">daniel.mcneela@gmail.com</a>> wrote:<br clear="none"></div></div></div><blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr">Hi All,<div><br clear="none"></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 clear="none"></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 clear="none"></div><div>Thank you in advance for your help!</div><div><br clear="none"></div><div>Best,</div><div><br clear="none"></div><div>Daniel McNeela</div></div></div></div>
_______________________________________________<br clear="none">
Matplotlib-devel mailing list<br clear="none">
<a rel="nofollow" shape="rect" href="mailto:Matplotlib-devel@python.org" target="_blank">Matplotlib-devel@python.org</a><br clear="none">
<a rel="nofollow" shape="rect" href="https://mail.python.org/mailman/listinfo/matplotlib-devel" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-devel</a><br clear="none">
</blockquote></div>
</blockquote></div><br clear="none"></div>
<br clear="none">_______________________________________________<br clear="none">
Matplotlib-devel mailing list<br clear="none">
<a rel="nofollow" shape="rect" href="mailto:Matplotlib-devel@python.org" target="_blank">Matplotlib-devel@python.org</a><br clear="none">
<a rel="nofollow" shape="rect" href="https://mail.python.org/mailman/listinfo/matplotlib-devel" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-devel</a><br clear="none">
<br clear="none"></blockquote></div></div></div></div><br><div>_______________________________________________<br clear="none">Matplotlib-devel mailing list<br clear="none"><a shape="rect" href="mailto:Matplotlib-devel@python.org" target="_blank">Matplotlib-devel@python.org</a><br clear="none"><a shape="rect" href="https://mail.python.org/mailman/listinfo/matplotlib-devel" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-devel</a><br clear="none"></div><br><br></div> </div></div></div> </div> </div></div></div></blockquote></div><br></div>