matplotlib.backend_tools
Abstract base classes define the primitives for Tools. These tools are used by matplotlib.backend_managers.ToolManager
-
ToolBase - Simple stateless tool
-
ToolToggleBase - Tool that has two states, only one Toggle tool can be active at any given time for the same
matplotlib.backend_managers.ToolManager
-
class matplotlib.backend_tools.AxisScaleBase(*args, **kwargs)[source] -
Bases:
matplotlib.backend_tools.ToolToggleBaseBase Tool to toggle between linear and logarithmic
-
disable(event)[source] -
Disable the toggle tool
triggercall this method whentoggledis True.This can happen in different circumstances
- Click on the toolbar tool button
- Call to
matplotlib.backend_managers.ToolManager.trigger_tool - Another
ToolToggleBasederived tool is triggered (from the sameToolManager)
-
-
class matplotlib.backend_tools.ConfigureSubplotsBase(toolmanager, name)[source] -
Bases:
matplotlib.backend_tools.ToolBaseBase tool for the configuration of subplots
-
description = 'Configure subplots'
-
image = 'subplots'
-
-
class matplotlib.backend_tools.Cursors[source] -
Bases:
objectSimple namespace for cursor reference
-
HAND = 0
-
MOVE = 3
-
POINTER = 1
-
SELECT_REGION = 2
-
WAIT = 4
-
-
class matplotlib.backend_tools.RubberbandBase(toolmanager, name)[source] -
Bases:
matplotlib.backend_tools.ToolBaseDraw and remove rubberband
-
draw_rubberband(*data)[source] -
Draw rubberband
This method must get implemented per backend
-
remove_rubberband()[source] -
Remove rubberband
This method should get implemented per backend
-
trigger(sender, event, data)[source] -
Call
draw_rubberbandorremove_rubberbandbased on data
-
-
class matplotlib.backend_tools.SaveFigureBase(toolmanager, name)[source] -
Bases:
matplotlib.backend_tools.ToolBaseBase tool for figure saving
-
default_keymap = ['s', 'ctrl+s']
-
description = 'Save the figure'
-
image = 'filesave'
-
-
class matplotlib.backend_tools.SetCursorBase(*args, **kwargs)[source] -
Bases:
matplotlib.backend_tools.ToolBaseChange to the current cursor while inaxes
This tool, keeps track of all
ToolToggleBasederived tools, and calls set_cursor when a tool gets triggered-
set_cursor(cursor)[source] -
Set the cursor
This method has to be implemented per backend
-
set_figure(figure)[source] -
Assign a figure to the tool
Parameters: - figure: `Figure`
-
-
class matplotlib.backend_tools.ToolBack(toolmanager, name)[source] -
Bases:
matplotlib.backend_tools.ViewsPositionsBaseMove back up the view lim stack
-
default_keymap = ['left', 'c', 'backspace']
-
description = 'Back to previous view'
-
image = 'back'
-
-
class matplotlib.backend_tools.ToolBase(toolmanager, name)[source] -
Bases:
objectBase tool class
A base tool, only implements
triggermethod or not method at all. The tool is instantiated bymatplotlib.backend_managers.ToolManagerAttributes: - toolmanager: `matplotlib.backend_managers.ToolManager`
-
ToolManager that controls this Tool
- figure: `FigureCanvas`
-
Figure instance that is affected by this Tool
- name: String
-
Used as Id of the tool, has to be unique among tools of the same ToolManager
-
canvas
-
default_keymap = None -
Keymap to associate with this tool
String: List of comma separated keys that will be used to call this tool when the keypress event of self.figure.canvas is emitted
-
description = None -
Description of the Tool
String: If the Tool is included in the Toolbar this text is used as a Tooltip
-
destroy()[source] -
Destroy the tool
This method is called when the tool is removed by
matplotlib.backend_managers.ToolManager.remove_tool
-
figure
-
image = None -
Filename of the image
String: Filename of the image to use in the toolbar. If None, the
nameis used as a label in the toolbar button
-
name -
Tool Id
-
set_figure(figure)[source] -
Assign a figure to the tool
Parameters: - figure: `Figure`
-
toolmanager
-
trigger(sender, event, data=None)[source] -
Called when this tool gets used
This method is called by
matplotlib.backend_managers.ToolManager.trigger_toolParameters: - event: `Event`
-
The Canvas event that caused this tool to be called
- sender: object
-
Object that requested the tool to be triggered
- data: object
-
Extra data
-
class matplotlib.backend_tools.ToolCursorPosition(*args, **kwargs)[source] -
Bases:
matplotlib.backend_tools.ToolBaseSend message with the current pointer position
This tool runs in the background reporting the position of the cursor
-
send_message(event)[source]
-
set_figure(figure)[source] -
Assign a figure to the tool
Parameters: - figure: `Figure`
-
-
Bases:
matplotlib.backend_tools.ToolBaseTool to enable all axes for toolmanager interaction
-
Called when this tool gets used
This method is called by
matplotlib.backend_managers.ToolManager.trigger_toolParameters: - event: `Event`
-
The Canvas event that caused this tool to be called
- sender: object
-
Object that requested the tool to be triggered
- data: object
-
Extra data
-
-
Bases:
matplotlib.backend_tools.ToolBaseTool to enable a specific axes for toolmanager interaction
-
Called when this tool gets used
This method is called by
matplotlib.backend_managers.ToolManager.trigger_toolParameters: - event: `Event`
-
The Canvas event that caused this tool to be called
- sender: object
-
Object that requested the tool to be triggered
- data: object
-
Extra data
-
-
class matplotlib.backend_tools.ToolForward(toolmanager, name)[source] -
Bases:
matplotlib.backend_tools.ViewsPositionsBaseMove forward in the view lim stack
-
default_keymap = ['right', 'v']
-
description = 'Forward to next view'
-
image = 'forward'
-
-
class matplotlib.backend_tools.ToolFullScreen(*args, **kwargs)[source] -
Bases:
matplotlib.backend_tools.ToolToggleBaseTool to toggle full screen
-
default_keymap = ['f', 'ctrl+f']
-
description = 'Toogle Fullscreen mode'
-
disable(event)[source] -
Disable the toggle tool
triggercall this method whentoggledis True.This can happen in different circumstances
- Click on the toolbar tool button
- Call to
matplotlib.backend_managers.ToolManager.trigger_tool - Another
ToolToggleBasederived tool is triggered (from the sameToolManager)
-
enable(event)[source] -
Enable the toggle tool
triggercalls this method whentoggledis False
-
-
class matplotlib.backend_tools.ToolGrid(toolmanager, name)[source] -
Bases:
matplotlib.backend_tools._ToolGridBaseTool to toggle the major grids of the figure
-
default_keymap = ['g']
-
description = 'Toogle major grids'
-
-
class matplotlib.backend_tools.ToolHome(toolmanager, name)[source] -
Bases:
matplotlib.backend_tools.ViewsPositionsBaseRestore the original view lim
-
default_keymap = ['h', 'r', 'home']
-
description = 'Reset original view'
-
image = 'home'
-
-
class matplotlib.backend_tools.ToolMinorGrid(toolmanager, name)[source] -
Bases:
matplotlib.backend_tools._ToolGridBaseTool to toggle the major and minor grids of the figure
-
default_keymap = ['G']
-
description = 'Toogle major and minor grids'
-
-
class matplotlib.backend_tools.ToolPan(*args)[source] -
Bases:
matplotlib.backend_tools.ZoomPanBasePan axes with left mouse, zoom with right
-
cursor = 3
-
default_keymap = ['p']
-
description = 'Pan axes with left mouse, zoom with right'
-
image = 'move'
-
radio_group = 'default'
-
-
class matplotlib.backend_tools.ToolQuit(toolmanager, name)[source] -
Bases:
matplotlib.backend_tools.ToolBaseTool to call the figure manager destroy method
-
default_keymap = ['ctrl+w', 'cmd+w', 'q']
-
description = 'Quit the figure'
-
trigger(sender, event, data=None)[source] -
Called when this tool gets used
This method is called by
matplotlib.backend_managers.ToolManager.trigger_toolParameters: - event: `Event`
-
The Canvas event that caused this tool to be called
- sender: object
-
Object that requested the tool to be triggered
- data: object
-
Extra data
-
-
class matplotlib.backend_tools.ToolQuitAll(toolmanager, name)[source] -
Bases:
matplotlib.backend_tools.ToolBaseTool to call the figure manager destroy method
-
default_keymap = ['W', 'cmd+W', 'Q']
-
description = 'Quit all figures'
-
trigger(sender, event, data=None)[source] -
Called when this tool gets used
This method is called by
matplotlib.backend_managers.ToolManager.trigger_toolParameters: - event: `Event`
-
The Canvas event that caused this tool to be called
- sender: object
-
Object that requested the tool to be triggered
- data: object
-
Extra data
-
-
class matplotlib.backend_tools.ToolToggleBase(*args, **kwargs)[source] -
Bases:
matplotlib.backend_tools.ToolBaseToggleable tool
Every time it is triggered, it switches between enable and disable
Parameters: - ``*args``
-
Variable length argument to be used by the Tool
- ``**kwargs``
-
toggledif present and True, sets the initial state of the Tool Arbitrary keyword arguments to be consumed by the Tool
-
cursor = None -
Cursor to use when the tool is active
-
default_toggled = False -
Default of toggled state
-
disable(event=None)[source] -
Disable the toggle tool
triggercall this method whentoggledis True.This can happen in different circumstances
- Click on the toolbar tool button
- Call to
matplotlib.backend_managers.ToolManager.trigger_tool - Another
ToolToggleBasederived tool is triggered (from the sameToolManager)
-
radio_group = None -
Attribute to group 'radio' like tools (mutually exclusive)
String that identifies the group or None if not belonging to a group
-
set_figure(figure)[source] -
Assign a figure to the tool
Parameters: - figure: `Figure`
-
toggled -
State of the toggled tool
-
class matplotlib.backend_tools.ToolViewsPositions(*args, **kwargs)[source] -
Bases:
matplotlib.backend_tools.ToolBaseAuxiliary Tool to handle changes in views and positions
Runs in the background and should get used by all the tools that need to access the figure's history of views and positions, e.g.
-
add_figure(figure)[source] -
Add the current figure to the stack of views and positions
-
back()[source] -
Back one step in the stack of views and positions
-
clear(figure)[source] -
Reset the axes stack
-
forward()[source] -
Forward one step in the stack of views and positions
-
home()[source] -
Recall the first view and position from the stack
-
push_current(figure=None)[source] -
Push the current view limits and position onto their respective stacks
-
refresh_locators()[source] -
Redraw the canvases, update the locators
-
update_home_views(figure=None)[source] -
Make sure that self.home_views has an entry for all axes present in the figure
-
update_view()[source] -
Update the view limits and position for each axes from the current stack position. If any axes are present in the figure that aren't in the current stack position, use the home view limits for those axes and don't update any positions.
-
-
class matplotlib.backend_tools.ToolXScale(*args, **kwargs)[source] -
Bases:
matplotlib.backend_tools.AxisScaleBaseTool to toggle between linear and logarithmic scales on the X axis
-
default_keymap = ['k', 'L']
-
description = 'Toogle Scale X axis'
-
set_scale(ax, scale)[source]
-
-
class matplotlib.backend_tools.ToolYScale(*args, **kwargs)[source] -
Bases:
matplotlib.backend_tools.AxisScaleBaseTool to toggle between linear and logarithmic scales on the Y axis
-
default_keymap = ['l']
-
description = 'Toogle Scale Y axis'
-
set_scale(ax, scale)[source]
-
-
class matplotlib.backend_tools.ToolZoom(*args)[source] -
Bases:
matplotlib.backend_tools.ZoomPanBaseZoom to rectangle
-
cursor = 2
-
default_keymap = ['o']
-
description = 'Zoom to rectangle'
-
image = 'zoom_to_rect'
-
radio_group = 'default'
-
-
class matplotlib.backend_tools.ViewsPositionsBase(toolmanager, name)[source] -
Bases:
matplotlib.backend_tools.ToolBaseBase class for
ToolHome,ToolBackandToolForward-
trigger(sender, event, data=None)[source] -
Called when this tool gets used
This method is called by
matplotlib.backend_managers.ToolManager.trigger_toolParameters: - event: `Event`
-
The Canvas event that caused this tool to be called
- sender: object
-
Object that requested the tool to be triggered
- data: object
-
Extra data
-
-
class matplotlib.backend_tools.ZoomPanBase(*args)[source] -
Bases:
matplotlib.backend_tools.ToolToggleBaseBase class for
ToolZoomandToolPan-
disable(event)[source] -
Release the canvas and disconnect press/release events
-
enable(event)[source] -
Connect press/release events and lock the canvas
-
scroll_zoom(event)[source]
-
-
matplotlib.backend_tools.add_tools_to_container(container, tools=[['navigation', ['home', 'back', 'forward']], ['zoompan', ['pan', 'zoom', 'subplots']], ['io', ['save']]])[source] -
Add multiple tools to the container.
Parameters: - container: Container
-
backend_bases.ToolContainerBaseobject that will get the tools added -
tools : list, optional -
List in the form [[group1, [tool1, tool2 ...]], [group2, [...]]] Where the tools given by tool1, and tool2 will display in group1. See
add_toolfor details.
-
matplotlib.backend_tools.add_tools_to_manager(toolmanager, tools={'allnav': <class 'matplotlib.backend_tools.ToolEnableAllNavigation'>, 'back': <class 'matplotlib.backend_tools.ToolBack'>, 'cursor': 'ToolSetCursor', 'forward': <class 'matplotlib.backend_tools.ToolForward'>, 'fullscreen': <class 'matplotlib.backend_tools.ToolFullScreen'>, 'grid': <class 'matplotlib.backend_tools.ToolGrid'>, 'grid_minor': <class 'matplotlib.backend_tools.ToolMinorGrid'>, 'home': <class 'matplotlib.backend_tools.ToolHome'>, 'nav': <class 'matplotlib.backend_tools.ToolEnableNavigation'>, 'pan': <class 'matplotlib.backend_tools.ToolPan'>, 'position': <class 'matplotlib.backend_tools.ToolCursorPosition'>, 'quit': <class 'matplotlib.backend_tools.ToolQuit'>, 'quit_all': <class 'matplotlib.backend_tools.ToolQuitAll'>, 'rubberband': 'ToolRubberband', 'save': 'ToolSaveFigure', 'subplots': 'ToolConfigureSubplots', 'viewpos': <class 'matplotlib.backend_tools.ToolViewsPositions'>, 'xscale': <class 'matplotlib.backend_tools.ToolXScale'>, 'yscale': <class 'matplotlib.backend_tools.ToolYScale'>, 'zoom': <class 'matplotlib.backend_tools.ToolZoom'>})[source] -
Add multiple tools to
ToolManagerParameters: - toolmanager: ToolManager
-
backend_managers.ToolManagerobject that will get the tools added -
tools : {str: class_like}, optional -
The tools to add in a {name: tool} dict, see
add_toolfor more info.
-
matplotlib.backend_tools.default_toolbar_tools = [['navigation', ['home', 'back', 'forward']], ['zoompan', ['pan', 'zoom', 'subplots']], ['io', ['save']]] -
Default tools in the toolbar
-
matplotlib.backend_tools.default_tools = {'allnav': <class 'matplotlib.backend_tools.ToolEnableAllNavigation'>, 'back': <class 'matplotlib.backend_tools.ToolBack'>, 'cursor': 'ToolSetCursor', 'forward': <class 'matplotlib.backend_tools.ToolForward'>, 'fullscreen': <class 'matplotlib.backend_tools.ToolFullScreen'>, 'grid': <class 'matplotlib.backend_tools.ToolGrid'>, 'grid_minor': <class 'matplotlib.backend_tools.ToolMinorGrid'>, 'home': <class 'matplotlib.backend_tools.ToolHome'>, 'nav': <class 'matplotlib.backend_tools.ToolEnableNavigation'>, 'pan': <class 'matplotlib.backend_tools.ToolPan'>, 'position': <class 'matplotlib.backend_tools.ToolCursorPosition'>, 'quit': <class 'matplotlib.backend_tools.ToolQuit'>, 'quit_all': <class 'matplotlib.backend_tools.ToolQuitAll'>, 'rubberband': 'ToolRubberband', 'save': 'ToolSaveFigure', 'subplots': 'ToolConfigureSubplots', 'viewpos': <class 'matplotlib.backend_tools.ToolViewsPositions'>, 'xscale': <class 'matplotlib.backend_tools.ToolXScale'>, 'yscale': <class 'matplotlib.backend_tools.ToolYScale'>, 'zoom': <class 'matplotlib.backend_tools.ToolZoom'>} -
Default tools
© 2012–2018 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/2.2.3/api/backend_tools_api.html