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¶
Messages sent between the local and remote canvases. There is an identical class in
matplotlib_backend_localbecause 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'¶
Catch and log exceptions (with their tracebacks
- class cytoflowgui.matplotlib_backend_remote.FigureCanvasAggRemote(parent_conn, process_events, plot_lock, figure)¶
The canvas the figure renders into in the remote process (ie, the one where someone is calling pyplot.plot()
The main method for the thread that listens for messages from the local canvas
The main method for the thread that sends messages to the local canvas
- draw(*args, **kwargs)¶
When the canvas is instructed to draw itself, copy the Agg buffer out to a numpy array and send it to the local process.
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.
- cytoflowgui.matplotlib_backend_remote.new_figure_manager(num, *args, **kwargs)¶
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.tight_layout(self, *args, **kwargs)¶