From: James R. <jam...@gm...> - 2014-07-16 16:34:40
|
Hi, I just started working on MEP26 <https://github.com/matplotlib/matplotlib/wiki/MEP26> to create a stylesheet syntax & implementation for dynamic, artist-level stylesheets. There is still a lot of work to be done on the MEP, but hopefully it is a good starting point for discussion Thanks James |
From: Nelle V. <nel...@gm...> - 2014-07-18 16:10:04
|
Hi James, > Thanks for sharing the MEP - it's a really interesting idea, and the MEP > itself looks like a good start. > It is indeed a very interesting idea, and a challenging one! Thanks for tackling this problem. > I'd strongly encourage you to stick with standard CSS syntax/behaviour > instead of extending it. For example, the selector of "Axes.ylabel" would > be more consistent as "Axes .ylabel" (or perhaps "Axis.y .label"). > I actually think we need to focus on something easy to parse and easy to use, not necessarily stick to the CSS syntax and behaviour. Back in the day where I was doing web development and design integration, everyone seemed to hate CSS, so I am a bit curious and dubious about this choice. I think we need to be careful about the choice of the grammar and the API: we know there are tools that are "doing it right", and tools that aren't (matplotlib falls in the second category). Before trying our own recipe I suggest that we look elsewhere, on how other libraries are tackling this problem, to see if we can reuse some of the good ideas and avoid errors. I am thinking in particular about ggplot2 (which I have never used, but I hear is very nice). Thanks, Nelle > > Do you have ideas on how one or more stylesheets would be "attached" to a > particular figure, etc? > > Regards, > Richard Hattersley > > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > _______________________________________________ > Matplotlib-devel mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel > > |
From: jamesramm <jam...@gm...> - 2014-07-20 13:23:51
|
Nelle Varoquaux wrote >> I'd strongly encourage you to stick with standard CSS syntax/behaviour >> instead of extending it. For example, the selector of "Axes.ylabel" would >> be more consistent as "Axes .ylabel" (or perhaps "Axis.y .label"). >> > > I actually think we need to focus on something easy to parse and easy to > use, not necessarily stick to the CSS syntax and behaviour. Back in the > day > where I was doing web development and design integration, everyone seemed > to hate CSS, so I am a bit curious and dubious about this choice. We cannot stick with the 'standard' CSS syntax by necessity, simply because the standard CSS selectors and properties are defined from HTML and do not match with matplotlib. I.E we want to select by artist type, which doesn't exist in HTML and use properties such as linewidth. So, we would need to define a new syntax based on these tokens. I have updated MEP26 with a BNF form of a basic syntax to use - take a look! Another option would be to use the syntax for the ConfigParser module; this way we already have a parser :) Nelle Varoquaux wrote > I think we need to be careful about the choice of the grammar and the API: > we know there are tools that are "doing it right", and tools that aren't > (matplotlib falls in the second category). Before trying our own recipe I > suggest that we look elsewhere, on how other libraries are tackling this > problem, to see if we can reuse some of the good ideas and avoid errors. I > am thinking in particular about ggplot2 (which I have never used, but I > hear is very nice). > > Thanks, > Nelle I thought CSS would be a good language to base it on as it is a widely known and by far the most popular (as far as I know) 'stylesheet' language. Other libraries that use style sheets, based on some form of CSS are: Qt - Pyside/PyQt ('QSS') Mapnik ('CartoCSS') PyGal supports stylesheets (don't know much about this library) As I say, an alternative could be simply using the ConfigParser Richard Hattersley wrote >> >> Do you have ideas on how one or more stylesheets would be "attached" to a >> particular figure, etc? >> >> Regards, >> Richard Hattersley >> This is the big question. We need a standard way in which to traverse all the artists in a figure, filter them by the selectors and applying the property updates. The last part is easiest - the update() method on artists will accept a dictionary. We can simply ensure that our stylesheet rules are parsed into a dict structure (which is quite a common method to use). The hard part is a) Getting a complete figure description/traversing the artists. This is currently tricky, but I think the ideas proposed in MEP25 will make it much easier. b) Filtering artists Another problem is that we would generally want to treat artists which are solely for the construction of the Axes differently to those artists that define a plot. I.E we might want to define Line2D as having the colour red, but we want lines which compose the Axes to be black or grey. My initial proposal is to develop stylesheets for artist primitives only. But eventually we will want to style artist containers aswell. The problem matplotlib has is that the properties for artist containers are not uniform/intuitive. It generally has a API where artists which are 'contained' by other artists are set by calling properties...e.g. axes.set_ylabel(text = , etc...) I would prefer to be able to simply pass a class instance...e.g create an instance of Text() and pass that to set_ylabel() I believe this is similar to the Plotly API that is quite nice: https://plot.ly/python/line-and-scatter/ An ideal solution would be trying to seperate out the style of artists from the actual drawing/data PyGal accepts a `Style` instance as an arguement to it's plotting functions, which would be a good way to go. I would imagine setting stylesheets through the axes or figure methods (axes.setStyleSheet() or figure.setStyleSheet()). Via figure would require being able to differentiate between different axes - i.e. introducing the 'container' level syntax I mentioned above. I would imagine that this would eventually replace rcparams to define the default style. I would also like to see the default look of graphs moving away from the very dated, 90's style MATLAB appearance! Anyway, there are a lot of ideas above, some of which are feasible, some of which perhaps not, all of which need more thinking about! -- View this message in context: http://matplotlib.1069221.n5.nabble.com/MEP26-Artist-level-stylesheets-tp43664p43671.html Sent from the matplotlib - devel mailing list archive at Nabble.com. |
From: R H. <rha...@gm...> - 2014-07-21 09:38:59
|
On 20 July 2014 14:23, jamesramm <jam...@gm...> wrote: > We cannot stick with the 'standard' CSS syntax by necessity, simply because > the standard CSS selectors and properties are defined from HTML and do not > match with matplotlib. > I.E we want to select by artist type, which doesn't exist in HTML and use > properties such as linewidth. > I'm not sure what it is about CSS syntax that isn't up to the job. For example, SVG works with standard CSS syntax (see http://www.w3.org/TR/SVG/styling.html#StylingWithCSS). Perhaps we just have a different view of what constitutes CSS vs. HTML/SVG/whatever. The example in the SVG spec is: rect { fill: red; stroke: blue; stroke-width: 3 } But if we define the element name for a Line2D instance as "line2d" then CSS snippet could just become: line2d { stroke: blue; stroke-width: 3 } Sure, matplotlib doesn't define a genuine DOM, but I understand there is interest in moving to a model more like that. In which case, perhaps a good way to proceed in the meantime would be to have artists expose a DOM facade suitable for styling. (Perhaps even using SVG element conventions?) NB. matplotlib already uses pyparsing, so it would be pretty straightforward to knock together a parser for CSS (or whatever subset is needed). Or there are existing Python CSS parser libraries. > Qt - Pyside/PyQt ('QSS') > Mapnik ('CartoCSS') > PyGal supports stylesheets (don't know much about this library) > > If we don't use CSS then +1 for using some other standard. > As I say, an alternative could be simply using the ConfigParser > > > Richard Hattersley wrote > >> > >> Do you have ideas on how one or more stylesheets would be "attached" to > a > >> particular figure, etc? > >> > >> Regards, > >> Richard Hattersley > >> > > > b) Filtering artists > Another problem is that we would generally want to treat artists which are > solely for the construction of the Axes differently to those artists that > define a plot. I.E we might want to define Line2D as having the colour red, > but we want lines which compose the Axes to be black or grey. > My initial proposal is to develop stylesheets for artist primitives only. > But eventually we will want to style artist containers aswell. > The problem matplotlib has is that the properties for artist containers are > not uniform/intuitive. > It generally has a API where artists which are 'contained' by other artists > are set by calling properties...e.g. axes.set_ylabel(text = , etc...) > The DOM facade could help bridge the gap. For example, a "DOM" instance returned by an Axes object could pretend to have "text" element children. Styling those would route the style information back to the underlying Axes object. For example: text { font-size: 12pt; } axes text.ylabel { font-size: 10pt; } I would imagine setting stylesheets through the axes or figure methods > (axes.setStyleSheet() or figure.setStyleSheet()). Via figure would require > being able to differentiate between different axes - i.e. introducing the > 'container' level syntax I mentioned above. > > I would imagine that this would eventually replace rcparams to define the > default style. I would also like to see the default look of graphs moving > away from the very dated, 90's style MATLAB appearance! > That would be an excellent start. More complicated mechanisms can always be added later if necessary. Richard |
From: jamesramm <jam...@gm...> - 2014-07-21 13:48:15
|
R Hattersley wrote > I'm not sure what it is about CSS syntax that isn't up to the job. > Forexample, SVG works with standard CSS syntax > (seehttp://www.w3.org/TR/SVG/styling.html#StylingWithCSS). Perhaps we just > havea different view of what constitutes CSS vs. HTML/SVG/whatever.The > example in the SVG spec is: > rect { fill: red; stroke: blue; stroke-width: 3} > But if we define the element name for a Line2D instance as "line2d" > thenCSS snippet could just become: > line2d { stroke: blue; stroke-width: 3} You've just noted it: Line2D isn't a CSS selector..likewise, the properties we want to call upon (like linewidth) are not CSS attributes. There are many matplotlib properties that don't have an analogous CSS property/attribute (that I know of); we might aswell define the mpl properties in our 'CSS' subset.So we could base our language on CSS rules, but we need to define new tokens. This means writing, or more likely, extending a parser. Not huge, but not trivial. R Hattersley wrote > The DOM facade could help bridge the gap. For example, a "DOM" > instancereturned by an Axes object could pretend to have "text" element > children.Styling those would route the style information back to the > underlying Axesobject. For example: > text { font-size: 12pt;}axes text.ylabel { font-size: 10pt;} This could be one way. Another way that would fit and I quite like is similar to what is employed by mapnik/the tilemill, in that we simply have nested declaration blocks, e.g: Axes { gid: 'axes1'; autoscalex_on: True; ::ylabel { text: 'Y-Axis'; font-size: 10; } } I think this would be easier to parse and slightly clearer to read as it can be 'attached' to the artist container it refers to (imagine if there were 2 axes in a figure...). It is also easy to write in BNF, by just adding another option to the Declaration block: Rule := Selector '{' [Declaration] '}'Declaration := Attribute':' Value';' | Rule... But...small steps. I would start by introducing something for artist primitives and for selectively applying to primitives using the gid -- View this message in context: http://matplotlib.1069221.n5.nabble.com/MEP26-Artist-level-stylesheets-tp43664p43673.html Sent from the matplotlib - devel mailing list archive at Nabble.com. |
From: Thomas C. <tca...@gm...> - 2014-07-21 16:28:44
|
As a side note, SVG already has specs which extend css to apply to 2D graphics: www.w3.org/TR/SVGTiny12/styling.html so we don't need to entirely re-inventing the wheel. On Mon, Jul 21, 2014 at 9:48 AM, jamesramm <jam...@gm...> wrote: > R Hattersley wrote > I'm not sure what it is about CSS syntax that isn't up to the job. For > example, SVG works with standard CSS syntax (see > http://www.w3.org/TR/SVG/styling.html#StylingWithCSS). Perhaps we just have > a different view of what constitutes CSS vs. HTML/SVG/whatever. The example > in the SVG spec is: > > rect { > fill: red; > stroke: blue; > stroke-width: 3 > } > > But if we define the element name for a Line2D instance as "line2d" then CSS > snippet could just become: > > line2d { > stroke: blue; > stroke-width: 3 > } > > You've just noted it: Line2D isn't a CSS selector..likewise, the properties > we want to call upon (like linewidth) are not CSS attributes. There are many > matplotlib properties that don't have an analogous CSS property/attribute > (that I know of); we might aswell define the mpl properties in our 'CSS' > subset. So we could base our language on CSS rules, but we need to define > new tokens. This means writing, or more likely, extending a parser. Not > huge, but not trivial. > > R Hattersley wrote > The DOM facade could help bridge the gap. For example, a "DOM" instance > returned by an Axes object could pretend to have "text" element children. > Styling those would route the style information back to the underlying Axes > object. For example: > > text { > font-size: 12pt; > } > > axes text.ylabel { > font-size: 10pt; > } > > This could be one way. Another way that would fit and I quite like is > similar to what is employed by mapnik/the tilemill, in that we simply have > nested declaration blocks, e.g: > > Axes { > gid: 'axes1'; > autoscalex_on: True; > ::ylabel { > text: 'Y-Axis'; > font-size: 10; > } > } > > I think this would be easier to parse and slightly clearer to read as it can > be 'attached' to the artist container it refers to (imagine if there were 2 > axes in a figure...). It is also easy to write in BNF, by just adding > another option to the Declaration block: > > Rule := Selector '{' [Declaration] '}' > > Declaration := Attribute':' Value';' | Rule > > ... > > But...small steps. I would start by introducing something for artist > primitives and for selectively applying to primitives using the gid > ________________________________ > View this message in context: Re: MEP26: Artist-level stylesheets > > Sent from the matplotlib - devel mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > _______________________________________________ > Matplotlib-devel mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel > -- Thomas Caswell tca...@gm... |
From: R H. <rha...@gm...> - 2014-07-21 16:40:07
|
On 21 July 2014 14:48, jamesramm <jam...@gm...> wrote: > You've just noted it: Line2D isn't a CSS selector CSS doesn't define any particular element names - it just operates on element names in a document tree. So a standard CSS parser will work just as well with "line2d { ... }" as it would with "h1 { ... }". On 21 July 2014 14:48, jamesramm <jam...@gm...> wrote: > ..likewise, the properties we want to call upon (like linewidth) are not > CSS attributes. Agreed - not all properties are standard CSS properties, so I was suggesting borrowing SVG properties to augment the list. NB. That would make the property controlling line width be called "stroke-width". But whatever names we choose, a CSS parser doesn't care what the names are. But really the issue is not so much about CSS and SVG-styling-properties - it is whether to use existing standards or not. Clearly I'm in favour of adopting standards. But perhaps there is another standard set of CSS styling properties which would be a closer match to matplotlib? Perhaps CSS is not the answer at all, and something like SLD/SE would be better? (I suspect not! But there could easily be other technologies I'm not aware of!) Axes { > gid: 'axes1'; > autoscalex_on: True; > ::ylabel { > text: 'Y-Axis'; > font-size: 10; > } > } > > I think this would be easier to parse and slightly clearer to read as it > can be 'attached' to the artist container it refers to (imagine if there > were 2 axes in a figure...) In the case of two Axes, the CSS version would be: Axes#axes1 { border: 1px solid black; } Axes#axes2 { border: 2px dashed green; } |
From: R H. <rha...@gm...> - 2014-07-21 17:01:21
|
On 21 July 2014 17:40, R Hattersley <rha...@gm...> wrote: > In the case of two Axes, the CSS version would be: > > Axes#axes1 { > border: 1px solid black; > } > > Axes#axes2 { > border: 2px dashed green; > } > > Or if you want to borrow from more advanced selector syntax, you could do fun stuff like: Axes:nth-child(odd) { border: 1px solid black; } Axes:nth-child(even) { border: 2px dashed green; } |
From: jamesramm <jam...@gm...> - 2014-08-10 07:40:50
|
I have updated MEP26 to include discussion on 'decoupling' the style from artists and having a generic Style class. (copied over from the github issue): I have been thinking that a good way to get stylesheets in, would be if the 'style' of an artist was entirely independent. I.E a single property which points to some kind of 'style' object. This way, style objects could be created on their own (programatically, or by some other means (Stylesheets!)) and then applied to artists at will (programatically, or by some other means (a stylesheet parser....)). Then I thought...when it comes to drawing, the style **is** entirely independent - it has been transferred to the `GraphicsContext` object. So all that is needed is to expose this object at the artist level and we can create styles! I created a very minimal example to explain here: https://github.com/JamesRamm/mpl_experiment Basically, it just provides a `Style` class (which is just `GraphicsContextBase` propertified and with a new function to generate one from a dict) and a minimal reimplementation of Line2D and Text to show how it would be used for both. Just run run.py (and have a look at it) to see how the user would use style objects. (Note it is a bit convoluted as I have not added any axes plotting routines, so a Line2D needs to be manually created and added). Basically, this involves reimplementing the `draw` method to use the `style` property rather than creating a new `GraphicsContext` instance. It also has the benefits that you could create 1 style object and apply it to multiple artists, or tweak a couple of properties on each...which is nicer than using individual get/set methods on artists (IMO). So the API could potentially become something like: arts = axes.plot(xdata, ydata) #Note not providing any 'style' info myStyle = Style.from_dict({'color': '#484D7A', 'linewidth': 1.9, 'linestyle': 'dashed'}) arts.style = myStyle arts.style.color = '#FFFFFF' or: myStyle = Style() axes.plot([0,1],[0,1], style = myStyle) -- View this message in context: http://matplotlib.1069221.n5.nabble.com/MEP26-Artist-level-stylesheets-tp43664p43770.html Sent from the matplotlib - devel mailing list archive at Nabble.com. |
From: Drain, T. R (392P) <the...@jp...> - 2014-08-11 14:34:03
Attachments:
styles.html
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Plotting Styles â Monte Documentation</title> <link rel="stylesheet" href="styles_files/montedoc.css" type="text/css"> <link rel="stylesheet" href="styles_files/pygments.css" type="text/css"> </head> <body role="document"> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="section" id="plotting-styles"> <span id="plot2d-styles"></span><h1>Plotting Styles</h1> <div class="toctree-wrapper compound"> </div> <p>MONTE styles allow you to customize the look of your plots easily and to maintain a consistent style on a large number of plots. Styles are used to control how plot elements look (color, marker style, line style, font, etc.) and not how the plot is structured (line vs. marker, which tick formatter to use, etc.).</p> <p>They can be combined and chained together hierarchically. They can be edited programmaticaly via the mpython command shell, using the MONTE style editor GUI, or in a text editor.</p> <p>All of these examples assume that you have imported the plot and style manager into your script:</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">mpylab</span> <span class="kn">from</span> <span class="nn">mpy.plot.style</span> <span class="kn">import</span> <span class="n">mgr</span> <span class="k">as</span> <span class="n">smgr</span> </pre></div> </div> <hr class="docutils"> <table class="monte-quicklink-table docutils" border="1"> <colgroup> <col width="15%"> <col width="85%"> </colgroup> </table> <hr class="docutils"> <div class="section" id="overview"> <span id="plot2d-styles-overview"></span><h2>Overview</h2> <p>The style system has two primary user interfaces: the style manager class, and the style class. The style manager is responsible for creating styles, applying styles to plots, saving and loading styles, and remembering which styles were applied to which plots so they can be automatically updated.</p> <p>The style class is responsible for storing the set of properties to change in the plot. Styles have a variety of display parameters, applying to different parts of the plot. Each parameter can be set or unset. When the style is applied to a plot, those parameters which are set will be implemented; those parameters which are unset will be ignored.</p> <p>The structure of a style reflects the structure of a figure: in a figure, there are usually several contained objects (for example, an Axes object, a Line object, etc.). Likewise, in a style the parameters are organized by the type of object they affect: there are portions that affect only Axes objects, only Line objects, etc.</p> <p>The main style structure has some default attributes (bgColor, fgColor, line, patch, text) which apply to any appropriate plot element. If you set a property in the text attribute of a style, it will apply to any text in the plot (which is a nice way to control fonts, colors, etc). The figure and axes attributes are used to control specific parts of the plot (e.g. axes.xAxes applies just to the X axis and axes.yAxes applies just to the Y axes).</p> <p>The basic <a class="reference internal" href="http://monte/doc/current/source/mpy/plot/style/MplSubStyle.html#mpy-plot-style-mplsubstyle"><em>MplStyle</em></a> structure looks like this:</p> <blockquote> <div><table class="docutils" border="1"> <colgroup> <col width="15%"> <col width="20%"> <col width="65%"> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head"><strong>Property</strong></th> <th class="head"><strong>Type</strong></th> <th class="head"><strong>Description</strong></th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>axes</td> <td><a class="reference internal" href="http://monte/doc/current/userguide/plot2d/axes.html#plot2d-axes-styling"><em>Sub-Style</em></a></td> <td>Controls how to style an Axes and all itâs components.</td> </tr> <tr class="row-odd"><td>bgColor</td> <td><a class="reference internal" href="http://monte/doc/current/userguide/plot2d/color.html#plot2d-color"><em>color</em></a></td> <td>The default background color to use for a sub-style if none is is specified (i.e. the default background color).</td> </tr> <tr class="row-even"><td>fgColor</td> <td><a class="reference internal" href="http://monte/doc/current/userguide/plot2d/color.html#plot2d-color"><em>color</em></a></td> <td>The default foreground color to use for a sub-style if none is is specified (i.e. the default foreground color).</td> </tr> <tr class="row-odd"><td>figure</td> <td><a class="reference internal" href="http://monte/doc/current/userguide/plot2d/figure.html#plot2d-figure-styling"><em>Sub-Style</em></a></td> <td>Controls how to style a Figure.</td> </tr> <tr class="row-even"><td>line</td> <td><a class="reference internal" href="http://monte/doc/current/userguide/plot2d/lines.html#plot2d-lines-styling"><em>Sub-Style</em></a></td> <td>This specifies the style properties for line elements plotted on an Axes.</td> </tr> <tr class="row-odd"><td>patch</td> <td><a class="reference internal" href="http://monte/doc/current/userguide/plot2d/patches.html#plot2d-patches-styling"><em>Sub-Style</em></a></td> <td>This specifies the style properties for patch elements plotted on an Axes.</td> </tr> <tr class="row-even"><td>text</td> <td><a class="reference internal" href="http://monte/doc/current/userguide/plot2d/text.html#plot2d-text-styling"><em>Sub-Style</em></a></td> <td>The default text style to use. Sub-style elements may override for specific pieces of text.</td> </tr> </tbody> </table> </div></blockquote> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">The full list of available parameters can be found here: <a class="reference internal" href="http://monte/doc/current/userguide/plot2d/style_index.html#plot2d-style-index"><em>Style Index</em></a></p> </div> <hr class="docutils"> </div> <div class="section" id="style-creation"> <span id="plot2d-styles-create"></span><h2>Style Creation</h2> <p>Styles are created by calling the manager create method with the name of the style. Once the style has been created, set the parameters on the style using the names of the style attributes (see the top level style structure above for the possible names)</p> <div class="highlight-python"><div class="highlight"><pre><span class="c"># Create the style</span> <span class="n">style</span> <span class="o">=</span> <span class="n">smgr</span><span class="o">.</span><span class="n">create</span><span class="p">(</span> <span class="s">"Big Title"</span> <span class="p">)</span> <span class="c"># Change the axes title font.</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">title</span><span class="o">.</span><span class="n">font</span><span class="o">.</span><span class="n">family</span> <span class="o">=</span> <span class="s">"sans-serif"</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">title</span><span class="o">.</span><span class="n">font</span><span class="o">.</span><span class="n">size</span> <span class="o">=</span> <span class="mi">24</span> </pre></div> </div> <p>You can also pass a dictionary of style attributes to the create method to create and initialize the style in one call. The keys of the dictionary are the string form of the variable path: so the variable style.this.parameter.path becomes the dictionary key âthis.parameter.pathâ. The value associated with each key needs to be of the proper type for the parameter; some require floating point values, integers, booleans, or other strings.</p> <div class="highlight-python"><div class="highlight"><pre><span class="c"># Create the style</span> <span class="n">style</span> <span class="o">=</span> <span class="n">smgr</span><span class="o">.</span><span class="n">create</span><span class="p">(</span> <span class="s">"Big Title"</span><span class="p">,</span> <span class="p">{</span> <span class="s">"axes.title.font.family"</span> <span class="p">:</span> <span class="s">"sans-serif"</span><span class="p">,</span> <span class="s">"axes.title.font.size"</span> <span class="p">:</span> <span class="mi">24</span><span class="p">,</span> <span class="p">}</span> <span class="p">)</span> </pre></div> </div> <p>When defining a style, you can optionally name a parent style. When the style is applied, the parent style is automatically applied first. This means that a child style will overwrite the settings contained in the parent style, if and when those styles conflict.</p> <div class="highlight-python"><div class="highlight"><pre><span class="c"># Create the style to make fonts larger and easier to read.</span> <span class="n">s1</span> <span class="o">=</span> <span class="n">smgr</span><span class="o">.</span><span class="n">create</span><span class="p">(</span> <span class="s">"Big Text"</span> <span class="p">)</span> <span class="n">s1</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">font</span><span class="o">.</span><span class="n">scale</span> <span class="o">=</span> <span class="mf">1.5</span> <span class="c"># Create a new style, with a parent style</span> <span class="n">s2</span> <span class="o">=</span> <span class="n">smgr</span><span class="o">.</span><span class="n">create</span><span class="p">(</span> <span class="s">'Presentation'</span><span class="p">,</span> <span class="n">parent</span><span class="o">=</span><span class="s">'Big Text'</span> <span class="p">)</span> <span class="c"># Set something particular to the child style</span> <span class="n">s2</span><span class="o">.</span><span class="n">figure</span><span class="o">.</span><span class="n">width</span> <span class="o">=</span> <span class="mi">800</span> <span class="n">s2</span><span class="o">.</span><span class="n">figure</span><span class="o">.</span><span class="n">height</span> <span class="o">=</span> <span class="mi">600</span> <span class="c"># Big Text will be applied before the other parts of Presentation</span> <span class="n">smgr</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span> <span class="n">fig</span><span class="p">,</span> <span class="s">'Presentation'</span> <span class="p">)</span> </pre></div> </div> <p>It should be noted that in the above example the âBig Textâ style is <em>not</em> overwritten when we create the âPresentationâ style. This is because when we create styles in this manner, they are automatically registered and stored in a style manager class. They can then be access later by name.</p> </div> <div class="section" id="setting-attributes"> <h2>Setting Attributes</h2> <p>Each Style object has a set of parameters affecting how plots are displayed. The parameters are unset by default; they will not affect the display of a plot unless they are set. In an existing style object, you can use Pythonâs dot syntax to access and set parameters.</p> <p>To access an already defined style, use the find() method on the manager</p> <div class="highlight-python"><div class="highlight"><pre><span class="c"># Find a previous define dstyle</span> <span class="n">style</span> <span class="o">=</span> <span class="n">smgr</span><span class="o">.</span><span class="n">find</span><span class="p">(</span> <span class="s">"Big Text"</span> <span class="p">)</span> <span class="c"># Change some of the style attributes</span> <span class="n">style</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">font</span><span class="o">.</span><span class="n">size</span> <span class="o">=</span> <span class="mi">16</span> </pre></div> </div> </div> <div class="section" id="applying-styles-to-a-plot"> <h2>Applying Styles to a Plot</h2> <p>Styles can be applied to any matplotlib plot element (figures, axes, axis, lines, etc). Applying the style to the figure is most common use case. When you apply a style to a figure, it will search the figure for various plot elements and axes and recursively apply the same style to them (the same is true when calling apply only on the axes).</p> <p>The style attributes dictate which matplotlib elements are modified. So the attribute axes.bgColor will only change the color of the axes while the attribute figure.bgColor will change the background for the figure.</p> <p>Style are applied using the apply method on the manager. You can pass in the style object or the name of the style to apply.</p> <div class="highlight-python"><div class="highlight"><pre><span class="n">fig</span><span class="p">,</span> <span class="n">ax</span> <span class="o">=</span> <span class="n">mpylab</span><span class="o">.</span><span class="n">subplots</span><span class="p">()</span> <span class="n">lines</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">],</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]</span> <span class="p">)</span> <span class="n">ax</span><span class="o">.</span><span class="n">set_title</span><span class="p">(</span> <span class="s">"This is the Title"</span> <span class="p">)</span> <span class="c"># Create the style and set some fields</span> <span class="n">style</span> <span class="o">=</span> <span class="n">smgr</span><span class="o">.</span><span class="n">create</span><span class="p">(</span> <span class="s">"Big Title"</span> <span class="p">)</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">title</span><span class="o">.</span><span class="n">font</span><span class="o">.</span><span class="n">family</span> <span class="o">=</span> <span class="s">"sans-serif"</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">title</span><span class="o">.</span><span class="n">font</span><span class="o">.</span><span class="n">size</span> <span class="o">=</span> <span class="mi">24</span> <span class="c"># Apply the style to the figure.</span> <span class="n">smgr</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span> <span class="n">fig</span><span class="p">,</span> <span class="n">style</span> <span class="p">)</span> <span class="c"># Apply a list of styles to just the lines.</span> <span class="n">smgr</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span> <span class="n">lines</span><span class="p">,</span> <span class="p">[</span> <span class="s">"Dashed Lines"</span><span class="p">,</span> <span class="s">"Blue Lines"</span><span class="p">,</span> <span class="s">"Bold Lines"</span> <span class="p">]</span> <span class="p">)</span> </pre></div> </div> <p>The style manager will recursively walk down through the input plot element and apply the style. So if a plot contains four subplots, the axes style will be applied to each of the four subplots and the text style will apply to all the text in the plot. If you want to apply the style only the input object (say an input figure), pass recurse=False to the apply method.</p> <div class="highlight-python"><div class="highlight"><pre><span class="c"># Apply the style only to the figure</span> <span class="n">smgr</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span> <span class="n">fig</span><span class="p">,</span> <span class="s">'Figure Style'</span><span class="p">,</span> <span class="n">recurse</span><span class="o">=</span><span class="bp">False</span> <span class="p">)</span> </pre></div> </div> </div> <div class="section" id="updating-and-re-applying-styles"> <h2>Updating and Re-applying Styles</h2> <p>When the manager applyes a style to the figure (or to any other other plotting element), the manager will remember what style was applied to which element, so if you later modify any styles, the changes can be automatically applied to the plot elements by calling the reapply method.</p> <div class="highlight-python"><div class="highlight"><pre><span class="c"># Modify the style</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">title</span><span class="o">.</span><span class="n">font</span><span class="o">.</span><span class="n">size</span> <span class="o">=</span> <span class="mi">16</span> <span class="c"># Apply the update to everything that is currently using it.</span> <span class="n">smgr</span><span class="o">.</span><span class="n">reapply</span><span class="p">()</span> </pre></div> </div> <p>This will change the fonts from size 24 (the original âBig Titleâ size) to the new size of 16 and update the plot. The reapply() method will update any and all plots that have styes applied to them.</p> </div> <div class="section" id="saving-loading"> <h2>Saving & Loading</h2> <p>The style manager can be used to save and load styles to a persistent form. Each style is saved into a file with the form âStyle_Name.mpystyleâ. Style files are human readable, Python files and may be edited by the user. Styles are NOT automatically saved and loaded by the manager (though that could change based on user feedback).</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">Style names including a space â â will be changed to use an underscore â_â when saved as a .mpystyle file. For Example, a style named âDSS 16â will be saved as âDSS_16.mpystyleâ.</p> </div> <p>To save the current set of styles, use the manager save method. To load all the available styles, use the load method.</p> <div class="highlight-python"><div class="highlight"><pre><span class="c"># Save the current styles to $HOME/.masar/styles</span> <span class="n">smgr</span><span class="o">.</span><span class="n">save</span><span class="p">()</span> <span class="c"># Save the current styles to the local directory.</span> <span class="n">smgr</span><span class="o">.</span><span class="n">save</span><span class="p">(</span> <span class="s">"."</span> <span class="p">)</span> <span class="c"># Load all available styles.</span> <span class="n">smgr</span><span class="o">.</span><span class="n">load</span><span class="p">()</span> </pre></div> </div> <p>When loading styles, the manager will use a search path that looks for styles in the following order (high priority to low priority):</p> <ol class="arabic simple"> <li>The current directory.</li> <li>The userâs home directory: $HOME/.masar/styles/</li> <li>The <a class="reference internal" href="http://monte/doc/current/source/Monte/index.html#monte"><em>Monte</em></a> installed data directory: $MONTEDIR/share/monte/styles</li> </ol> <p>Styles that are defined in more than one of these locations will use the first definition. This way, each user can override and customize certain <a class="reference internal" href="http://monte/doc/current/source/Monte/index.html#monte"><em>Monte</em></a> styles to their liking; they can also use different directories to try out different style options in parallel. You can change the list of directories to look in by modifying your STYLEPATH environment variable.</p> <p>You can also manipulate the loading and saving of styles in your Python script directly. The âpathâ variable on the style manager is a simple Python list of directory names. By changing the path, you can change what styles are loaded:</p> <div class="highlight-python"><div class="highlight"><pre><span class="c"># Add a search path and load the styles.</span> <span class="n">smgr</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> <span class="s">"/nav/proj/scripts/styles"</span> <span class="p">)</span> <span class="n">smgr</span><span class="o">.</span><span class="n">load</span><span class="p">()</span> </pre></div> </div> </div> <div class="section" id="tagging-plot-elements"> <h2>Tagging Plot Elements</h2> <p id="plot2d-styles-tags">Tagging or style tags are way to filter which plot elements (figure, axes, lines, etc) a style is applied to by setting a tag (string name) to a plot element. The script that creates the plot tags each element with a name. When a style is applied to an element, the tag input can be specified to limit which elements get changed.</p> <p>Letâs say you have a plot that shows two lines for each DSN complex (Goldstone, Canberra, and Madrid). The plotting script has access to those lines and knows which complex they are a part of but the lines are hard to get to after the plotting script is finished. If the plotting script tags the lines with the complex name like this:</p> <div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">createPlot</span><span class="p">():</span> <span class="n">fig</span><span class="p">,</span> <span class="n">ax</span> <span class="o">=</span> <span class="n">mpylab</span><span class="o">.</span><span class="n">subplots</span><span class="p">()</span> <span class="c"># create data to plot, layout plot, etc.</span> <span class="n">l</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span> <span class="n">gldX</span><span class="p">,</span> <span class="n">gldY</span> <span class="p">)</span> <span class="n">smgr</span><span class="o">.</span><span class="n">tag</span><span class="p">(</span> <span class="n">l</span><span class="p">,</span> <span class="s">"Goldstone"</span> <span class="p">)</span> <span class="n">l</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span> <span class="n">madX</span><span class="p">,</span> <span class="n">madY</span> <span class="p">)</span> <span class="n">smgr</span><span class="o">.</span><span class="n">tag</span><span class="p">(</span> <span class="n">l</span><span class="p">,</span> <span class="s">"Madrid"</span> <span class="p">)</span> <span class="n">l</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span> <span class="n">canX</span><span class="p">,</span> <span class="n">canY</span> <span class="p">)</span> <span class="n">smgr</span><span class="o">.</span><span class="n">tag</span><span class="p">(</span> <span class="n">l</span><span class="p">,</span> <span class="s">"Canberra"</span> <span class="p">)</span> <span class="k">return</span> <span class="n">fig</span> </pre></div> </div> <p>The calling script can use those tags to apply styles to the individual lines without having direct access to them. Both the apply() and set() functions can use the tag keyword to filter which elements are used.</p> <div class="highlight-python"><div class="highlight"><pre><span class="n">fig</span> <span class="o">=</span> <span class="n">createPlot</span><span class="p">()</span> <span class="c"># Apply the 'Goldstone Style' to elements tagged Goldstone</span> <span class="n">smgr</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span> <span class="n">fig</span><span class="p">,</span> <span class="s">"Goldstone Style"</span><span class="p">,</span> <span class="n">tag</span><span class="o">=</span><span class="s">"Goldstone"</span> <span class="p">)</span> <span class="c"># Change every line tagged Canberra to be blue.</span> <span class="n">smgr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> <span class="n">fig</span><span class="p">,</span> <span class="p">{</span> <span class="s">'line.color'</span> <span class="p">:</span> <span class="s">'blue'</span> <span class="p">},</span> <span class="n">tag</span><span class="o">=</span><span class="s">"Canberra"</span> <span class="p">)</span> </pre></div> </div> <p>Tags are a powerful tool that allows you to write complicated plotting scripts and then control individual elements in those plots using styles from outside the plotting script.</p> </div> <div class="section" id="setting-attributes-and-unmanaged-styles"> <span id="plot2d-styles-unmanaged"></span><h2>Setting Attributes and Unmanaged Styles</h2> <p>The style system can also be used to quickly set plot attributes without creating a style by calling the manager set() method. This method can accept either a single style attribute or a dictionary of style attributes and can use the tag system to filter which plot elements are set.</p> <div class="highlight-python"><div class="highlight"><pre><span class="c"># Change the background color to black.</span> <span class="n">smgr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> <span class="n">fig</span><span class="p">,</span> <span class="s">"bgColor"</span><span class="p">,</span> <span class="s">"black"</span> <span class="p">)</span> <span class="c"># Change the multiple attributes.</span> <span class="n">smgr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> <span class="n">fig</span><span class="p">,</span> <span class="p">{</span> <span class="s">"bgColor"</span> <span class="p">:</span> <span class="s">"black"</span><span class="p">,</span> <span class="s">"fgColor"</span> <span class="p">:</span> <span class="s">"white"</span><span class="p">,</span> <span class="s">"text.font.scale"</span> <span class="p">:</span> <span class="mf">1.25</span> <span class="p">}</span> <span class="p">)</span> <span class="c"># Change lines tagged 'DSS 14' to gold.</span> <span class="n">smgr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> <span class="n">fig</span><span class="p">,</span> <span class="s">"line.color"</span><span class="p">,</span> <span class="s">"gold"</span><span class="p">,</span> <span class="n">tag</span><span class="o">=</span><span class="s">"DSS 14"</span> <span class="p">)</span> </pre></div> </div> <p>An âunmanagedâ style can be created using the style constructor and applied directly to a plot. The style manager will have no knowlege of this style and so reapply will not work, and the style will not be saved.</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">mpy.plot.style</span> <span class="kn">as</span> <span class="nn">S</span> <span class="c"># Unmanaged style - won't be saved.</span> <span class="n">style</span> <span class="o">=</span> <span class="n">S</span><span class="o">.</span><span class="n">MplStyle</span><span class="p">(</span> <span class="s">'dummy'</span> <span class="p">)</span> <span class="c"># Must use style.apply(), smgr.apply() won't work.</span> <span class="n">style</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span> <span class="n">fig</span> <span class="p">)</span> </pre></div> </div> <hr class="docutils"> </div> <div class="section" id="an-example"> <span id="plot2d-styles-example"></span><h2>An Example</h2> <p>Following is a more complete example on how to make the plot at the top of this page:</p> <div class="highlight-python"><div class="highlight"><pre><span class="c"># import some modules</span> <span class="kn">import</span> <span class="nn">mpylab</span> <span class="kn">from</span> <span class="nn">mpy.plot.style</span> <span class="kn">import</span> <span class="n">mgr</span> <span class="k">as</span> <span class="n">smgr</span> <span class="c"># create the plot</span> <span class="n">fig</span><span class="p">,</span> <span class="n">ax</span> <span class="o">=</span> <span class="n">mpylab</span><span class="o">.</span><span class="n">subplots</span><span class="p">()</span> <span class="n">xdata</span> <span class="o">=</span> <span class="p">[</span> <span class="mi">1</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mf">2.5</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mf">3.5</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mf">4.5</span><span class="p">,</span> <span class="mf">4.75</span><span class="p">,</span> <span class="mi">5</span> <span class="p">]</span> <span class="n">ydata</span> <span class="o">=</span> <span class="p">[</span> <span class="mi">1</span><span class="p">,</span> <span class="mf">1.75</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mf">2.75</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mf">2.75</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mf">2.25</span><span class="p">,</span> <span class="mf">2.75</span><span class="p">,</span> <span class="mi">3</span> <span class="p">]</span> <span class="n">line</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span> <span class="n">xdata</span><span class="p">,</span> <span class="n">ydata</span> <span class="p">)</span> <span class="n">rect</span> <span class="o">=</span> <span class="n">mpylab</span><span class="o">.</span><span class="n">Rectangle</span><span class="p">(</span> <span class="p">(</span><span class="mf">2.8</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">),</span> <span class="mf">0.4</span><span class="p">,</span> <span class="mf">1.2</span> <span class="p">)</span> <span class="n">ax</span><span class="o">.</span><span class="n">add_patch</span><span class="p">(</span> <span class="n">rect</span> <span class="p">)</span> <span class="n">figTitle</span> <span class="o">=</span> <span class="n">fig</span><span class="o">.</span><span class="n">suptitle</span><span class="p">(</span> <span class="s">"Figure Title"</span> <span class="p">)</span> <span class="n">axTitle</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">set_title</span><span class="p">(</span> <span class="s">"Axes Title"</span> <span class="p">)</span> <span class="n">xLabel</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span> <span class="s">"X-Axis Label"</span> <span class="p">)</span> <span class="n">yLabel</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span> <span class="s">"Y-Axis Label"</span> <span class="p">)</span> <span class="n">figText</span> <span class="o">=</span> <span class="n">fig</span><span class="o">.</span><span class="n">text</span><span class="p">(</span> <span class="mf">0.02</span><span class="p">,</span> <span class="mf">0.02</span><span class="p">,</span> <span class="s">"FigureText"</span> <span class="p">)</span> <span class="n">txt</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">text</span><span class="p">(</span> <span class="mf">4.2</span><span class="p">,</span> <span class="mf">1.1</span><span class="p">,</span> <span class="s">"Text"</span> <span class="p">)</span> <span class="c"># Create the style</span> <span class="n">style</span> <span class="o">=</span> <span class="n">smgr</span><span class="o">.</span><span class="n">create</span><span class="p">(</span> <span class="s">"My Style"</span> <span class="p">)</span> <span class="n">style</span><span class="o">.</span><span class="n">bgColor</span> <span class="o">=</span> <span class="s">'white'</span> <span class="n">style</span><span class="o">.</span><span class="n">fgColor</span> <span class="o">=</span> <span class="s">'black'</span> <span class="c"># Figure</span> <span class="n">style</span><span class="o">.</span><span class="n">figure</span><span class="o">.</span><span class="n">width</span> <span class="o">=</span> <span class="mi">10</span> <span class="n">style</span><span class="o">.</span><span class="n">figure</span><span class="o">.</span><span class="n">height</span> <span class="o">=</span> <span class="mi">10</span> <span class="c"># Axes</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">axisBelow</span> <span class="o">=</span> <span class="bp">True</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">leftEdge</span><span class="o">.</span><span class="n">color</span> <span class="o">=</span> <span class="s">'magenta'</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">leftEdge</span><span class="o">.</span><span class="n">width</span> <span class="o">=</span> <span class="mi">5</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">leftEdge</span><span class="o">.</span><span class="n">style</span> <span class="o">=</span> <span class="s">'--'</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">bottomEdge</span><span class="o">.</span><span class="n">color</span> <span class="o">=</span> <span class="s">'magenta'</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">bottomEdge</span><span class="o">.</span><span class="n">width</span> <span class="o">=</span> <span class="mi">5</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">bottomEdge</span><span class="o">.</span><span class="n">style</span> <span class="o">=</span> <span class="s">'dashed'</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">topEdge</span><span class="o">.</span><span class="n">visible</span> <span class="o">=</span> <span class="bp">False</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">rightEdge</span><span class="o">.</span><span class="n">visible</span> <span class="o">=</span> <span class="bp">False</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">title</span><span class="o">.</span><span class="n">font</span><span class="o">.</span><span class="n">scale</span> <span class="o">=</span> <span class="mf">2.0</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">title</span><span class="o">.</span><span class="n">font</span><span class="o">.</span><span class="n">family</span> <span class="o">=</span> <span class="s">'sans-serif'</span> <span class="c"># X-Axis</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">xAxis</span><span class="o">.</span><span class="n">autoscale</span> <span class="o">=</span> <span class="bp">True</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">xAxis</span><span class="o">.</span><span class="n">dataMargin</span> <span class="o">=</span> <span class="mf">0.1</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">xAxis</span><span class="o">.</span><span class="n">label</span><span class="o">.</span><span class="n">font</span><span class="o">.</span><span class="n">scale</span> <span class="o">=</span> <span class="mf">1.2</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">xAxis</span><span class="o">.</span><span class="n">majorTicks</span><span class="o">.</span><span class="n">labels</span><span class="o">.</span><span class="n">font</span><span class="o">.</span><span class="n">scale</span> <span class="o">=</span> <span class="mf">0.75</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">xAxis</span><span class="o">.</span><span class="n">majorTicks</span><span class="o">.</span><span class="n">marks</span><span class="o">.</span><span class="n">visible</span> <span class="o">=</span> <span class="bp">True</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">xAxis</span><span class="o">.</span><span class="n">majorTicks</span><span class="o">.</span><span class="n">grid</span><span class="o">.</span><span class="n">visible</span> <span class="o">=</span> <span class="bp">True</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">xAxis</span><span class="o">.</span><span class="n">majorTicks</span><span class="o">.</span><span class="n">grid</span><span class="o">.</span><span class="n">color</span> <span class="o">=</span> <span class="s">'#B0B0B0'</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">xAxis</span><span class="o">.</span><span class="n">majorTicks</span><span class="o">.</span><span class="n">grid</span><span class="o">.</span><span class="n">width</span> <span class="o">=</span> <span class="mf">1.5</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">xAxis</span><span class="o">.</span><span class="n">majorTicks</span><span class="o">.</span><span class="n">grid</span><span class="o">.</span><span class="n">style</span> <span class="o">=</span> <span class="s">':'</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">xAxis</span><span class="o">.</span><span class="n">majorTicks</span><span class="o">.</span><span class="n">length</span> <span class="o">=</span> <span class="mf">15.0</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">xAxis</span><span class="o">.</span><span class="n">majorTicks</span><span class="o">.</span><span class="n">width</span> <span class="o">=</span> <span class="mf">1.5</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">xAxis</span><span class="o">.</span><span class="n">minorTicks</span><span class="o">.</span><span class="n">marks</span><span class="o">.</span><span class="n">visible</span> <span class="o">=</span> <span class="bp">True</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">xAxis</span><span class="o">.</span><span class="n">minorTicks</span><span class="o">.</span><span class="n">grid</span><span class="o">.</span><span class="n">visible</span> <span class="o">=</span> <span class="bp">True</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">xAxis</span><span class="o">.</span><span class="n">minorTicks</span><span class="o">.</span><span class="n">grid</span><span class="o">.</span><span class="n">color</span> <span class="o">=</span> <span class="s">'#B0B0B0'</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">xAxis</span><span class="o">.</span><span class="n">minorTicks</span><span class="o">.</span><span class="n">grid</span><span class="o">.</span><span class="n">width</span> <span class="o">=</span> <span class="mf">0.5</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">xAxis</span><span class="o">.</span><span class="n">minorTicks</span><span class="o">.</span><span class="n">grid</span><span class="o">.</span><span class="n">style</span> <span class="o">=</span> <span class="s">':'</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">xAxis</span><span class="o">.</span><span class="n">minorTicks</span><span class="o">.</span><span class="n">length</span> <span class="o">=</span> <span class="mf">5.0</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">xAxis</span><span class="o">.</span><span class="n">minorTicks</span><span class="o">.</span><span class="n">width</span> <span class="o">=</span> <span class="mf">0.5</span> <span class="c"># Y-Axis</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">yAxis</span> <span class="o">=</span> <span class="n">style</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">xAxis</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="c"># Lines</span> <span class="n">style</span><span class="o">.</span><span class="n">line</span><span class="o">.</span><span class="n">color</span> <span class="o">=</span> <span class="s">"blue"</span> <span class="n">style</span><span class="o">.</span><span class="n">line</span><span class="o">.</span><span class="n">style</span> <span class="o">=</span> <span class="s">'dash-dot'</span> <span class="n">style</span><span class="o">.</span><span class="n">line</span><span class="o">.</span><span class="n">width</span> <span class="o">=</span> <span class="mf">1.5</span> <span class="n">style</span><span class="o">.</span><span class="n">line</span><span class="o">.</span><span class="n">marker</span><span class="o">.</span><span class="n">color</span> <span class="o">=</span> <span class="s">'red'</span> <span class="n">style</span><span class="o">.</span><span class="n">line</span><span class="o">.</span><span class="n">marker</span><span class="o">.</span><span class="n">edgeColor</span> <span class="o">=</span> <span class="s">'green'</span> <span class="n">style</span><span class="o">.</span><span class="n">line</span><span class="o">.</span><span class="n">marker</span><span class="o">.</span><span class="n">edgeWidth</span> <span class="o">=</span> <span class="mi">3</span> <span class="n">style</span><span class="o">.</span><span class="n">line</span><span class="o">.</span><span class="n">marker</span><span class="o">.</span><span class="n">size</span> <span class="o">=</span> <span class="mi">20</span> <span class="n">style</span><span class="o">.</span><span class="n">line</span><span class="o">.</span><span class="n">marker</span><span class="o">.</span><span class="n">style</span> <span class="o">=</span> <span class="s">'circle'</span> <span class="n">style</span><span class="o">.</span><span class="n">line</span><span class="o">.</span><span class="n">marker</span><span class="o">.</span><span class="n">fill</span> <span class="o">=</span> <span class="s">'bottom'</span> <span class="c"># Patches</span> <span class="n">style</span><span class="o">.</span><span class="n">patch</span><span class="o">.</span><span class="n">color</span> <span class="o">=</span> <span class="s">'gold'</span> <span class="n">style</span><span class="o">.</span><span class="n">patch</span><span class="o">.</span><span class="n">filled</span> <span class="o">=</span> <span class="bp">True</span> <span class="n">style</span><span class="o">.</span><span class="n">patch</span><span class="o">.</span><span class="n">edgeColor</span> <span class="o">=</span> <span class="s">'purple'</span> <span class="n">style</span><span class="o">.</span><span class="n">patch</span><span class="o">.</span><span class="n">edgeWidth</span> <span class="o">=</span> <span class="mi">5</span> <span class="c"># Text</span> <span class="n">style</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">lineSpacing</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="n">style</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">font</span><span class="o">.</span><span class="n">size</span> <span class="o">=</span> <span class="mi">12</span> <span class="n">style</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">font</span><span class="o">.</span><span class="n">family</span> <span class="o">=</span> <span class="s">'monospace'</span> <span class="c"># apply the style</span> <span class="n">smgr</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span> <span class="n">fig</span><span class="p">,</span> <span class="n">style</span> <span class="p">)</span> </pre></div> </div> </div> </div> </div> </div> </div> <div class="clearer"></div> </div> <div class="footer" role="contentinfo"> © Copyright 2010, Caltech / Jet Propulsion Laboratory. Last updated on 2014-08-06@15:41:36 PDT. Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.3a0. </div> </body></html> |
From: jamesramm <jam...@gm...> - 2014-09-05 14:00:46
|
It would be great if we can see the code for the style system. However, for integration into MPL, rather than something which 'sits on top' of the existing API (I presume you are therefore working with getter/setter functions), the MEP I'm proposing is also trying to achieve the seperation of the 'style' of artists from their data/logic. The idea being that it heads towards a more streamlined and extensible API. Some of the techniques you are describing seem to cover some of the ideas put forth in the MEP, so if you can make the code available, it would be a great resource. -- View this message in context: http://matplotlib.1069221.n5.nabble.com/MEP26-Artist-level-stylesheets-tp43664p43893.html Sent from the matplotlib - devel mailing list archive at Nabble.com. |
From: Drain, T. R (392P) <the...@jp...> - 2014-09-12 18:23:45
|
OK. I'm working on getting permission from management to make this available but nothing is going to happen (end if fiscal year) until early October. I'll let you know more as soon as I can. It might be nice to start a list of functional requirements that a style system should meet. In implementing our style system for users, we found the style tagging system (see my previous emails) ended up being incredibly useful and wasn't an obvious need when we started. Maybe that's covered by the current MEP but it's not obvious to me. Ted ________________________________________ From: jamesramm [jam...@gm...] Sent: Friday, September 05, 2014 7:00 AM To: mat...@li... Subject: Re: [matplotlib-devel] MEP26: Artist-level stylesheets It would be great if we can see the code for the style system. However, for integration into MPL, rather than something which 'sits on top' of the existing API (I presume you are therefore working with getter/setter functions), the MEP I'm proposing is also trying to achieve the seperation of the 'style' of artists from their data/logic. The idea being that it heads towards a more streamlined and extensible API. Some of the techniques you are describing seem to cover some of the ideas put forth in the MEP, so if you can make the code available, it would be a great resource. -- View this message in context: http://matplotlib.1069221.n5.nabble.com/MEP26-Artist-level-stylesheets-tp43664p43893.html Sent from the matplotlib - devel mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ _______________________________________________ Matplotlib-devel mailing list Mat...@li... https://lists.sourceforge.net/lists/listinfo/matplotlib-devel |