Cool.

There is a lot of code there to digest so I don't have anything technically
sensible to say yet, but in principle/abstract this seems like a good idea.

This also ties back into the MEP25 (figure serialization) discussion and
the discussion I was having with Eric Firing in the comments of
https://github.com/matplotlib/matplotlib/pull/4172 (yes, a less than ideal
place) about adopting a more structured framework for mpl artists
attributes(ex make them into IPython Configurable/use traitlets) and the
larger discussion started at scipy last year about providing style sheets.

The current style library and rcparams tools provide (several) context
managers so you can mostly avoid damaging the global state.

The ability to apply style once the figure has been drawn is a feature
request I have seen go by several times.

Another major limitation of the rcparam approach is that to add new
parameters can modifying code pretty deep in the core of the library.

Tom

On Sat, Mar 7, 2015 at 9:39 PM Drain, Theodore R (392P) <
theodore.r.dr...@jpl.nasa.gov> wrote:

> Last year we implemented an object oriented plotting style system for our
> users and I was able to convince our management that we should open source
> it.  You can find it here:  https://github.com/nasa/mplStyle
>
> Many (most?) of the existing MPL style systems seem to be built around RC
> parameters which doesn't work very well for us.  For a large system that
> can create plots in many different scripts/GUI's, we really can't change
> global settings (RC's) to affect how a plot looks as it ends up screwing up
> plots in other areas.  So we designed an OO based style system that allows
> you to create/save/load styles and apply them to individual plot elements
> (text, lines, axes, figures, etc).
>
> This code was extracted from a much larger project so it wasn't really
> written as a standalone library or designed to follow MPL's naming and
> coding conventions.  i.e. don't assume the internals exhibit any great
> design - I was mostly concerned with getting a stand alone package that
> worked in the minimum amount of effort.  It does work fine, every method
> has documentation, and test cases are included (feel free to email me or
> use github if you find any problems) but my real hope is that it either
> serves as an inspiration for building a standard MPL OO style system (or
> perhaps it can be morphed into that over time).
>
> Some of the features include:
> - Object oriented style objects (no changes to global RC parameters)
> - Apply styles to whole figures or to individual plot elements (artists,
> patches, axes, etc)
> - Save and load styles into human editable files
> - Apply styles by name or by style object
> - Styles remember what they were applied to and can be told to re-apply
> after changes.  This is great way to try out style settings without having
> to regenerate a plot.
> - Plot elements can be tagged with a name.  The tag name can later be used
> as a target in the style application.  This is great feature for plotting
> libraries as it allows a script to create plot elements with a set of names
> and the caller can apply various styles to the plot elements by using those
> names.  This separates plot creation from plot styling and makes plotting
> code much easier to reuse as users don't need to edit the plotting script
> just to change the style of a line.
>
> Please take a look and let us know what you think.
> Ted
> ps: FYI for clarity I wasn't the primary author of this code - James Evans
> get's that honor with various contributions from a variety of people who
> work on our development team.
> ------------------------------------------------------------
> ------------------
> Dive into the World of Parallel Programming The Go Parallel Website,
> sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for
> all
> things parallel software development, from weekly thought leadership blogs
> to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> Matplotlib-devel mailing list
> Matplotlib-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to