cytoflowgui.matplotlib_backend_remote

A matplotlib backend that renders across a process boundary. This file has the “remote” canvas – the Agg renderer into which pyplot.plot() renders.

By default, matplotlib only works in one thread. For a GUI application, this is a problem because when matplotlib is working (ie, scaling a bunch of data points) the GUI freezes.

This module implements a matplotlib backend where the plotting done in one process (ie via pyplot, etc) shows up in a canvas running in another process (the GUI). The canvas is the interface across the process boundary: a “local” canvas, which is a GUI widget (in this case a QWidget) and a “remote” canvas (running in the process where pyplot.plot() etc. are used.) The remote canvas is a subclass of the Agg renderer; when draw() is called, the remote canvas pulls the current buffer out of the renderer and pushes it through a pipe to the local canvas, which draws it on the screen. blit() is implemented too.

This takes care of one direction of data flow, and would be enough if we were just plotting. However, we want to use matplotlib widgets as well, which means there’s data flowing from the local canvas to the remote canvas too. The local canvas is a subclass of FigureCanvasQTAgg, which is itself a sublcass of QWidget. The local canvas overrides several of the event handlers, passing the event information to the remote canvas which in turn runs the matplotlib event handlers.

class cytoflowgui.matplotlib_backend_remote.Msg[source]

Bases: object

Messages sent between the local and remote canvases. There is an identical class in matplotlib_backend_local because we don’t want these two modules requiring one another

DRAW = 'DRAW'
BLIT = 'BLIT'
WORKING = 'WORKING'
RESIZE_EVENT = 'RESIZE'
MOUSE_PRESS_EVENT = 'MOUSE_PRESS'
MOUSE_MOVE_EVENT = 'MOUSE_MOVE'
MOUSE_RELEASE_EVENT = 'MOUSE_RELEASE'
MOUSE_DOUBLE_CLICK_EVENT = 'MOUSE_DOUBLE_CLICK'
DPI = 'DPI'
PRINT = 'PRINT'
cytoflowgui.matplotlib_backend_remote.log_exception()[source]

Catch and log exceptions (with their tracebacks

class cytoflowgui.matplotlib_backend_remote.FigureCanvasAggRemote(parent_conn, process_events, plot_lock, figure)[source]

Bases: matplotlib.backends.backend_agg.FigureCanvasAgg

The canvas the figure renders into in the remote process (ie, the one where someone is calling pyplot.plot()

listen_for_local()[source]

The main method for the thread that listens for messages from the local canvas

send_to_local()[source]

The main method for the thread that sends messages to the local canvas

draw(*args, **kwargs)[source]

When the canvas is instructed to draw itself, copy the Agg buffer out to a numpy array and send it to the local process.

blit(bbox=None)[source]

When instructed to blit a bounding box, copy the region in the bounding box to a numpy array and send it to the local canvas.

set_working(working)[source]
cytoflowgui.matplotlib_backend_remote.new_figure_manager(num, *args, **kwargs)[source]

Create a new figure manager instance. This maintains the remote canvas as a singleton – else, each new canvas would need a copy of the pipes, locks, etc.

cytoflowgui.matplotlib_backend_remote.draw_if_interactive()[source]
cytoflowgui.matplotlib_backend_remote.show()[source]
cytoflowgui.matplotlib_backend_remote.FigureCanvas

alias of cytoflowgui.matplotlib_backend_remote.FigureCanvasAggRemote

cytoflowgui.matplotlib_backend_remote.tight_layout(self, *args, **kwargs)[source]