SeabornPlotStyle

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

Bases: Stoner.plot.formats.DefaultPlotStyle

A plotdtyle that makes use of the seaborn plotting package to make visually attractive plots.

stylename

The seaborn plot stlye to use - darkgrid, whitegrid, dark, white, or ticks

Type

str

context

The seaborn plot context for scaling elements - paper,notebook,talk, or poster

Type

str

palette

A name of a predefined seaborn palette.

Type

str

Example

"""Example plot style using Seaborn plot styling template."""
import os.path as path

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

filename = path.realpath(
    path.join(__home__, "..", "doc", "samples", "sample.txt")
)
d = Data(
    filename,
    setas="xyy",
    template=SeabornPlotStyle(
        stylename="dark", context="talk", palette="muted"
    ),
)
d.plot(multiple="y2")

(png, hires.png, pdf)

../_images/seabornstyle.png

Attributes Summary

context

Provide context getter.

palette

Provide palette getter.

show_legend

show_title

show_xlabel

show_ylabel

show_zlabel

stylename

Provide getter for stylename.

stylesheet

Horribly hacky method to traverse over the class heirarchy 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()

Override base method to apply seaborn style sheets.

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

context

Provide context getter.

palette

Provide palette getter.

show_legend = True
show_title = True
show_xlabel = True
show_ylabel = True
show_zlabel = True
stylename

Provide getter for stylename.

stylesheet

Horribly hacky method to traverse over the class heirarchy 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)

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.

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]

Override base method to apply seaborn style sheets.

clear()

Reset everything back o defaults.

customise()

Implement hook to customise plot.

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

customise_axes(ax, plot)

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)

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)

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