PYME.recipes.graphing module

class PYME.recipes.graphing.Plot(plot_callable=None)

Bases: object

This is a class that defines a plot method that can be called to generate a matplotlib figure.

The Plot class (or any subclass thereof) can be returned by recipe module with the actual plotting deferred until the plot() method is called. This facilitates the use of different matplotlib backends (as appropriate) depending on the context in which the recipe is running.

The Plot class should either be subclassed with plot() over-ridden, or instantiated with a callable (e.g. a lambda function). This is conceptually similar to how the python Thread class behaves.

The plot function defines a number of translators, for use in report templates or output modules

When the plot method has not been overridden, a callable function should be provided

Parameters
plot_callablea callable to generate the plots. Must return a matplotlib figure object
as_html()
Returns
The plot as an html string using mpld3
as_pdf(filename=None)
as_png(filename=None)
as_svg(filename=None)
plot()

Do the plot in whatever context we have activated. Can be over-ridden in derived classes

Returns
a matplotlib figure instance
class PYME.recipes.graphing.plotting_context(backend='SVG')

Bases: object