mpl gui#

Show#

mpl_gui.show

Show the figures and maybe block.

Interactivity#

mpl_gui.ion

Enable interactive mode.

mpl_gui.ioff

Disable interactive mode.

mpl_gui.is_interactive

Return whether plots are updated after every plotting command.

Figure Fabrication#

Un-managed#

mpl_gui.figure

Create a new figure

mpl_gui.subplots

Create a figure and a set of subplots.

mpl_gui.subplot_mosaic

Build a layout of Axes based on ASCII art or nested lists.

mpl_gui.promote_figure

Create a new figure manager instance.

Managed#

class mpl_gui.FigureRegistry(*, block=None, timeout=0, prefix='Figure ')[source]#

Bases: object

A registry to wrap the creation of figures and track them.

This instance will keep a hard reference to created Figures to ensure that they do not get garbage collected.

Parameters:
blockbool, optional

Whether to wait for all figures to be closed before returning from show_all.

If True block and run the GUI main loop until all figure windows are closed.

If False ensure that all figure windows are displayed and return immediately. In this case, you are responsible for ensuring that the event loop is running to have responsive figures.

Defaults to True in non-interactive mode and to False in interactive mode (see is_interactive).

timeoutfloat, optional

Default time to wait for all of the Figures to be closed if blocking.

If 0 block forever.

mpl_gui.FigureRegistry.figure

Create a new figure

mpl_gui.FigureRegistry.subplots

Create a figure and a set of subplots.

mpl_gui.FigureRegistry.subplot_mosaic

Build a layout of Axes based on ASCII art or nested lists.

mpl_gui.FigureRegistry.by_label

Return a dictionary of the current mapping labels -> figures.

mpl_gui.FigureRegistry.show_all

Show all of the Figures that the FigureRegistry knows about.

mpl_gui.FigureRegistry.close_all

Close all Figures know to this Registry.

class mpl_gui.FigureContext(*, forgive_failure=False, **kwargs)[source]#

Bases: FigureRegistry

Extends FigureRegistry to be used as a context manger.

All figures known to the Registry will be shown on exiting the context.

Parameters:
blockbool, optional

Whether to wait for all figures to be closed before returning from show_all.

If True block and run the GUI main loop until all figure windows are closed.

If False ensure that all figure windows are displayed and return immediately. In this case, you are responsible for ensuring that the event loop is running to have responsive figures.

Defaults to True in non-interactive mode and to False in interactive mode (see is_interactive).

timeoutfloat, optional

Default time to wait for all of the Figures to be closed if blocking.

If 0 block forever.

forgive_failurebool, optional

If True, block to show the figure before letting the exception propagate

Select the backend#

mpl_gui.select_gui_toolkit

Select the GUI toolkit to use.