DefaultPlotStyle

class Stoner.plot.formats.DefaultPlotStyle(*args, **kargs)[source]

Bases: MutableMapping

Produces a default plot style.

To produce alternative plot styles, create subclasses of this plot. Either override or create additional attributes to define rc Parameters (see Matplotlib documentation for available rc parameters) and override the :py:meth:Stoner.pot.formats.DefaultPlotStyle.customise` method to carry out additional plot formatting.

fig_width_pt

Preferred width of plot in points

Type:

float

show_xlabel

Show the title in the plot

Type:

bool

show_ylabel

Show the x-axis Labels

Type:

bool

show_zlabel

show the y-xaxis labels

Type:

bool

show_title

show the title

Type:

bool

show_legend

show the legend

Type:

bool

stylename

Name of the matplotlib style to use

Type:

string

stylesheet

Calculated list of stylesheets found by traversing the class hierarchy

Type:

list

Example
"""Example plot using default style."""
import os.path as path

from Stoner import Data, __home__
from Stoner.plot.formats import DefaultPlotStyle

filename = path.realpath(
    path.join(__home__, "..", "doc", "samples", "sample.txt")
)
d = Data(filename, setas="xy", template=DefaultPlotStyle)
d.plot()

(png, hires.png, pdf)

../_images/defaultstyle.png

Attributes Summary

show_legend

show_title

show_xlabel

show_ylabel

show_zlabel

stylename

stylesheet

Horribly hacky method to traverse over the class hierarchy for style sheet names.

subplot_settings

Methods Summary

__call__(**kargs)

Call the template object can manipulate the rcParams that will be set.

annotate(ix, multiple, plot, **kargs)

Call all the routines necessary to annotate the axes etc.

apply()

Update matplotlib rc parameters from any attributes starting template_.

clear()

Reset everything back o defaults.

customise()

Implement hook to customise plot.

customise_axes(ax, plot)

Implement hook for for when we have an axis to manipulate.

get(k[,d])

items()

keys()

new_figure([figure])

Create a new figure.

pop(k[,d])

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem()

as a 2-tuple; but raise KeyError if D is empty.

setdefault(k[,d])

update(*args, **kargs)

Update the template with new attributes from keyword arguments.

values()

Attributes Documentation

show_legend = True
show_title = True
show_xlabel = True
show_ylabel = True
show_zlabel = True
stylename = 'default'
stylesheet

Horribly hacky method to traverse over the class hierarchy for style sheet names.

subplot_settings = {'panels': {'title': (True, False, False), 'xlabel': (False, False, True), 'ylabel': (True, True, True), 'zlabel': (False, False, False)}, 'subplots': {'title': (True, True, True), 'xlabel': (True, True, True), 'ylabel': (True, True, True), 'zlabel': (False, False, False)}, 'y2': {'title': (True, False, False), 'xlabel': (True, False, False), 'ylabel': (True, True, True), 'zlabel': (False, False, False)}}

Methods Documentation

__call__(**kargs)[source]

Call the template object can manipulate the rcParams that will be set.

annotate(ix, multiple, plot, **kargs)[source]

Call all the routines necessary to annotate the axes etc.

Parameters:
  • ix (integer) – Index of current subplot

  • multiple (string) – how to handle multiple subplots

  • plot (Stoner.plot.PlotMixin) – The PlotMixin boject we’re working with

apply()[source]

Update matplotlib rc parameters from any attributes starting template_.

clear()[source]

Reset everything back o defaults.

customise()[source]

Implement hook to customise plot.

This method is supplied for sub classes to override to provide additional plot customisation after the rc parameters are updated from the class and instance attributes.

customise_axes(ax, plot)[source]

Implement hook for for when we have an axis to manipulate.

Parameters:

ax (matplotlib axes) – The axes to be modified by this function.

Note

In the DefaultPlotStyle class this method is used to set SI units plotting mode for all axes.

get(k[, d]) D[k] if k in D, else d.  d defaults to None.
items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
new_figure(figure=False, **kargs)[source]

Create a new figure.

This is called by PlotMixin to setup a new figure before we do anything.

pop(k[, d]) v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() (k, v), remove and return some (key, value) pair

as a 2-tuple; but raise KeyError if D is empty.

setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D
update(*args, **kargs)[source]

Update the template with new attributes from keyword arguments.

Up to one positional argument may be supplied

Keyword arguments may be supplied to set default parameters. Any Matplotlib rc parameter may be specified, with .’s replaced with _ and )_ replaced with __.

values() an object providing a view on D's values