You are reading an old version of the documentation (v3.1.1). For the latest version see
Version 3.1.2
Fork me on GitHub


Interactive figures in the IPython notebook

class matplotlib.backends.backend_nbagg.CommSocket(manager)[source]

Bases: object

Manages the Comm connection between IPython and the browser (client).

Comms are 2 way, with the CommSocket being able to publish a message via the send_json method, and handle a message with on_message. On the JS side figure.send_message and do the sending and receiving respectively.

on_message(self, message)[source]
send_binary(self, blob)[source]
send_json(self, content)[source]

alias of matplotlib.backends.backend_nbagg.FigureCanvasNbAgg

class matplotlib.backends.backend_nbagg.FigureCanvasNbAgg(*args, **kwargs)[source]

Bases: matplotlib.backends.backend_webagg_core.FigureCanvasWebAggCore

new_timer(self, *args, **kwargs)[source]

Creates a new backend-specific subclass of backend_bases.Timer. This is useful for getting periodic events through the backend's native event loop. Implemented only for backends with GUIs.

Other Parameters:
interval : scalar

Timer interval in milliseconds

callbacks : List[Tuple[callable, Tuple, Dict]]

Sequence of (func, args, kwargs) where func(*args, **kwargs) will be executed by the timer every interval.

callbacks which return False or 0 will be removed from the timer.


>>> timer = fig.canvas.new_timer(callbacks=[(f1, (1, ), {'a': 3}),])

alias of matplotlib.backends.backend_nbagg.FigureManagerNbAgg

class matplotlib.backends.backend_nbagg.FigureManagerNbAgg(canvas, num)[source]

Bases: matplotlib.backends.backend_webagg_core.FigureManagerWebAgg


alias of NavigationIPy


Clear up any closed Comms.

classmethod get_javascript(stream=None)[source]
remove_comm(self, comm_id)[source]

A special method to re-show the figure in the notebook.


For GUI backends, show the figure window and redraw. For non-GUI backends, raise an exception to be caught by show(), for an optional warning.

class matplotlib.backends.backend_nbagg.NavigationIPy(canvas)[source]

Bases: matplotlib.backends.backend_webagg_core.NavigationToolbar2WebAgg

toolitems = [('Home', 'Reset original view', 'fa fa-home icon-home', 'home'), ('Back', 'Back to previous view', 'fa fa-arrow-left icon-arrow-left', 'back'), ('Forward', 'Forward to next view', 'fa fa-arrow-right icon-arrow-right', 'forward'), (None, None, None, None), ('Pan', 'Pan axes with left mouse, zoom with right', 'fa fa-arrows icon-move', 'pan'), ('Zoom', 'Zoom to rectangle', 'fa fa-square-o icon-check-empty', 'zoom'), (None, None, None, None), ('Download', 'Download plot', 'fa fa-floppy-o icon-save', 'download')]

Return a string showing the figure and connection status for the backend.

This is intended as a diagnostic tool, and not for general use.

matplotlib.backends.backend_nbagg.new_figure_manager_given_figure(num, figure)

Create a new figure manager instance for the given figure.*args, block=None, **kwargs)

Show all figures.

show blocks by calling mainloop if block is True, or if it is None and we are neither in IPython's %pylab mode, nor in interactive mode.