pytools.viz.matrix.MatrixDrawer#

class pytools.viz.matrix.MatrixDrawer(style=None)[source]#

Drawer for matrices of numerical values.

Supports the following pre-defined styles:

Bases

Drawer [Matrix [Any], MatrixStyle]

Metaclasses

ABCMeta

Parameters

style (Union[MatrixStyle, str, None]) – the style to be used for drawing (default: "matplot")

Method summary

draw

Render the data using the style associated with this drawer.

get_default_style

Get the default style for this drawer.

get_named_styles

Get a mapping of names to style factories for all named styles recognized by this drawer's initializer.

get_style

Get a style object by name.

get_style_classes

Get all style classes available for this drawer type.

get_style_kwargs

Using the given data object, derive keyword arguments to be passed to the style's start_drawing() and finalize_drawing() methods.

Attribute summary

style

see Drawer.style

Definitions

_draw(data)[source]#

Core drawing method invoked my method draw().

Must be implemented by subclasses of Drawer.

Parameters

data (Matrix[Any]) – the data to be rendered

Return type

None

draw(data, *, title)#

Render the data using the style associated with this drawer.

Creates a thread-safe lock on this drawer, then calls the following methods in sequence:

  1. Method start_drawing() of this drawer’s style attribute, passing the title and additional keyword arguments obtained from this drawer’s get_style_kwargs()

  2. Method _draw(), passing along the data argument

  3. Method finalize_drawing() of this drawer’s style attribute, passing the keyword arguments obtained from this drawer’s get_style_kwargs()

Parameters
  • data (MatrixDrawer) – the data to be rendered

  • title (str) – the title of the resulting chart

Return type

None

classmethod get_default_style()[source]#

Get the default style for this drawer.

Return type

MatrixStyle

Returns

the default style for this drawer

classmethod get_named_styles()#

Get a mapping of names to style factories for all named styles recognized by this drawer’s initializer.

A factory is a class or function with no mandatory parameters.

Return type

AbstractSet[str]

classmethod get_style(name)#

Get a style object by name.

Parameters

name (str) – the name of the style

Return type

MatrixStyle

Returns

the style object

Raises

KeyError – if the style name is not recognized

classmethod get_style_classes()[source]#

Get all style classes available for this drawer type.

Return type

Iterable[type[MatrixStyle]]

Returns

an iterable of style classes

get_style_kwargs(data)[source]#

Using the given data object, derive keyword arguments to be passed to the style’s start_drawing() and finalize_drawing() methods.

Parameters

data (Matrix[Any]) – the data to be rendered

Return type

dict[str, Any]

Returns

the style attributes for the given data object

style: base.MatrixStyle#

see Drawer.style