matplotlib.backends.backend_webagg_core#

Displays Agg images in the browser, with interactivity.

matplotlib.backends.backend_webagg_core.FigureCanvas[source]#

alias of FigureCanvasWebAggCore

class matplotlib.backends.backend_webagg_core.FigureCanvasWebAggCore(*args, **kwargs)[source]#

Bases: FigureCanvasAgg

blit(bbox=None)[source]#

Blit the canvas in bbox (default entire canvas).

draw()[source]#

Render the Figure.

This method must walk the artist tree, even if no output is produced, because it triggers deferred work that users may want to access before saving output to disk. For example computing limits, auto-limits, and tick values.

draw_idle()[source]#

Request a widget redraw once control returns to the GUI event loop.

Even if multiple calls to draw_idle occur before control returns to the GUI event loop, the figure will only be rendered once.

Notes

Backends may choose to override the method and implement their own strategy to prevent multiple renderings.

get_diff_image()[source]#
handle_ack(event)[source]#
handle_button_press(event)[source]#
handle_button_release(event)[source]#
handle_dblclick(event)[source]#
handle_draw(event)[source]#
handle_event(event)[source]#
handle_figure_enter(event)[source]#
handle_figure_leave(event)[source]#
handle_key_press(event)[source]#
handle_key_release(event)[source]#
handle_motion_notify(event)[source]#
handle_refresh(event)[source]#
handle_resize(event)[source]#
handle_scroll(event)[source]#
handle_send_image_mode(event)[source]#
handle_set_device_pixel_ratio(event)[source]#
handle_set_dpi_ratio(event)[source]#
handle_toolbar_button(event)[source]#
handle_unknown_event(event)[source]#
manager_class[source]#

alias of FigureManagerWebAgg

send_event(event_type, **kwargs)[source]#
set_cursor(cursor)[source]#

Set the current cursor.

This may have no effect if the backend does not display anything.

If required by the backend, this method should trigger an update in the backend event loop after the cursor is set, as this method may be called e.g. before a long-running task during which the GUI is not updated.

Parameters:
cursorCursors

The cursor to display over the canvas. Note: some backends may change the cursor for the entire window.

set_image_mode(mode)[source]#

Set the image mode for any subsequent images which will be sent to the clients. The modes may currently be either 'full' or 'diff'.

Note: diff images may not contain transparency, therefore upon draw this mode may be changed if the resulting image has any transparent component.

show()[source]#
supports_blit = False#
matplotlib.backends.backend_webagg_core.FigureManager[source]#

alias of FigureManagerWebAgg

class matplotlib.backends.backend_webagg_core.FigureManagerWebAgg(canvas, num)[source]#

Bases: FigureManagerBase

ToolbarCls[source]#

alias of NavigationToolbar2WebAgg

add_web_socket(web_socket)[source]#
classmethod get_javascript(stream=None)[source]#
classmethod get_static_file_path()[source]#
get_window_title()[source]#

Return the title text of the window containing the figure, or None if there is no window (e.g., a PS backend).

handle_json(content)[source]#
refresh_all()[source]#
remove_web_socket(web_socket)[source]#
resize(w, h, forward=True)[source]#

For GUI backends, resize the window (in physical pixels).

set_window_title(title)[source]#

Set the title text of the window containing the figure.

This has no effect for non-GUI (e.g., PS) backends.

Examples

>>> fig = plt.figure()
>>> fig.canvas.manager.set_window_title('My figure')
show()[source]#

For GUI backends, show the figure window and redraw. For non-GUI backends, raise an exception, unless running headless (i.e. on Linux with an unset DISPLAY); this exception is converted to a warning in Figure.show.

class matplotlib.backends.backend_webagg_core.NavigationToolbar2WebAgg(canvas)[source]#

Bases: NavigationToolbar2

draw_rubberband(event, x0, y0, x1, y1)[source]#

Draw a rectangle rubberband to indicate zoom limits.

Note that it is not guaranteed that x0 <= x1 and y0 <= y1.

pan()[source]#

Toggle the pan/zoom tool.

Pan with left button, zoom with right.

remove_rubberband()[source]#

Remove the rubberband.

save_figure(*args)[source]#

Save the current figure

set_history_buttons()[source]#

Enable or disable the back/forward button.

set_message(message)[source]#

Display a message on toolbar or in status bar.

toolitems = [('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous view', 'back', 'back'), ('Forward', 'Forward to next view', 'forward', 'forward'), (None, None, None, None), ('Pan', 'Left button pans, Right button zooms\nx/y fixes axis, CTRL fixes aspect', 'move', 'pan'), ('Zoom', 'Zoom to rectangle\nx/y fixes axis', 'zoom_to_rect', 'zoom'), (None, None, None, None), ('Download', 'Download plot', 'filesave', 'download')]#
zoom()[source]#
class matplotlib.backends.backend_webagg_core.TimerAsyncio(*args, **kwargs)[source]#

Bases: TimerBase

Parameters:
intervalint, default: 1000ms

The time between timer events in milliseconds. Will be stored as timer.interval.

callbackslist[tuple[callable, tuple, dict]]

List of (func, args, kwargs) tuples that will be called upon timer events. This list is accessible as timer.callbacks and can be manipulated directly, or the functions add_callback and remove_callback can be used.

class matplotlib.backends.backend_webagg_core.TimerTornado(*args, **kwargs)[source]#

Bases: TimerBase

Parameters:
intervalint, default: 1000ms

The time between timer events in milliseconds. Will be stored as timer.interval.

callbackslist[tuple[callable, tuple, dict]]

List of (func, args, kwargs) tuples that will be called upon timer events. This list is accessible as timer.callbacks and can be manipulated directly, or the functions add_callback and remove_callback can be used.