pylbo.visualisation.figure_window

Module Contents

Classes

FigureWindow

Class to handle the top-level creation of figure windows. Assigns unique figure

InteractiveFigureWindow

Subclass to handle interactivity in the figure windows.

class pylbo.visualisation.figure_window.FigureWindow(fig: matplotlib.figure.Figure)[source]

Class to handle the top-level creation of figure windows. Assigns unique figure ids and takes care of figure, axes, and gridspec management.

Parameters:

fig (Figure) – The figure object.

fig

The figure object.

Type:

Figure

figsize

The size of the figure in inches.

Type:

tuple[int, int]

figure_id

The unique figure id.

Type:

str

property figure_ids: list[str][source]

Returns the list of figure ids.

figure_stack[source]
create_default_figure(figlabel: str, figsize: tuple[int, int]) tuple[matplotlib.figure.Figure, matplotlib.axes.Axes][source]

Creates a default figure with a 1x1 subplot.

Parameters:
  • figlabel (str) – The label of the figure.

  • figsize (tuple[int, int]) – The size of the figure.

Returns:

  • fig (~matplotlib.figure.Figure) – The figure on which to draw.

  • ax (~matplotlib.axes.Axes) – The axes on which to draw.

_generate_figure_id(figlabel: str) str[source]

Generates a unique figure id.

Parameters:

figlabel (str) – The label of the figure.

Returns:

figure_id – The unique figure id of the form “figure_type-x” where x is an integer.

Return type:

str

add_to_stack() None[source]

Adds the figure to the stack.

add_subplot_axes(ax: matplotlib.axes.Axes, loc: str = 'right', share: str = None, apply_tight_layout: bool = True)[source]

Adds a new subplot to a given matplotlib subplot, essentially “splitting” the axis into two. Position and placement depend on the loc argument. When called on a more complex subplot layout the overall gridspec remains untouched, only the ax object has its gridspec modified. On return, tight_layout() is called by default to prevent overlapping labels.

Parameters:
  • ax (Axes) – The axes object, this will be “split” and a new axes will be added to the figure.

  • loc (str) – The location of the new axes. Should be one of “left”, “right”, “top”, “bottom”. Defaults to “right”.

  • share (str) – Can be “x”, “y” or “all”. This locks axes zooming between both subplots.

  • apply_tight_layout (bool) – Whether to call tight_layout() on the figure before return.

Raises:

ValueError – If the loc argument is invalid.

Returns:

The axes instance that was added.

Return type:

Axes

draw() None[source]
redraw() None[source]
save(filename: str, **kwargs) None[source]

Saves the current figure.

Parameters:
  • filename (str, PathLike) – The filename to which the current figure is saved.

  • kwargs – Default keyword arguments passed to savefig().

show()[source]

Shows the selected figure

class pylbo.visualisation.figure_window.InteractiveFigureWindow(fig: matplotlib.figure.Figure)[source]

Bases: FigureWindow

Subclass to handle interactivity in the figure windows.

redraw() None[source]
connect_callbacks() None[source]

Connects all callbacks to the canvas

disconnect_callbacks() None[source]

Disconnects all callbacks from the canvas

make_legend_interactive(legendhandler: pylbo.visualisation.legend_handler.LegendHandler) None[source]

Makes the legend interactive.

Parameters:

legendhandler (LegendHandler) – The legend handler.

add_eigenfunction_interface(efhandler: pylbo.visualisation.eigenfunctions.eigfunc_interface.EigenfunctionInterface) None[source]

Adds an eigenfunction interface to the figure.

Parameters:
  • efhandler () –

  • EigenfunctionInterface – The eigenfunction interface.