Skip to content

Deprecate toggling axes navigatability using the keyboard. #16529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions doc/api/next_api_changes/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,12 @@ The following validators, defined in `.rcsetup`, are deprecated:
``validate_ps_papersize``, ``validate_legend_log``. To test whether an rcParam
value would be acceptable, one can test e.g. ``rc = RcParams(); rc[k] = v``
raises an exception.

Toggling axes navigation from the keyboard using "a" and digit keys
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Axes navigation can still be toggled programmatically using
`.Axes.set_navigate`.

The following related APIs are also deprecated:
``backend_tools.ToolEnableAllNavigation``,
``backend_tools.ToolEnableNavigation``, and ``rcParams["keymap.all_axes"]``.
63 changes: 9 additions & 54 deletions doc/missing-references.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,45 +145,6 @@
"lib/matplotlib/transforms.py:docstring of matplotlib.transforms.IdentityTransform.transform_affine:21",
"lib/matplotlib/transforms.py:docstring of matplotlib.transforms.IdentityTransform.transform_non_affine:20"
],
"transforms.Bbox.bounds": [
"doc/api/prev_api_changes/api_changes_0.98.0.rst:91"
],
"transforms.Bbox.intervalx": [
"doc/api/prev_api_changes/api_changes_0.98.0.rst:99"
],
"transforms.Bbox.intervaly": [
"doc/api/prev_api_changes/api_changes_0.98.0.rst:102"
],
"transforms.Bbox.x0": [
"doc/api/prev_api_changes/api_changes_0.98.0.rst:105"
],
"transforms.Bbox.x1": [
"doc/api/prev_api_changes/api_changes_0.98.0.rst:113"
],
"transforms.Bbox.y0": [
"doc/api/prev_api_changes/api_changes_0.98.0.rst:109"
],
"transforms.Bbox.y1": [
"doc/api/prev_api_changes/api_changes_0.98.0.rst:117"
],
"transforms.BboxBase.height": [
"doc/api/prev_api_changes/api_changes_0.98.0.rst:96"
],
"transforms.BboxBase.width": [
"doc/api/prev_api_changes/api_changes_0.98.0.rst:93"
],
"transforms.BboxBase.xmax": [
"doc/api/prev_api_changes/api_changes_0.98.0.rst:113"
],
"transforms.BboxBase.xmin": [
"doc/api/prev_api_changes/api_changes_0.98.0.rst:105"
],
"transforms.BboxBase.ymax": [
"doc/api/prev_api_changes/api_changes_0.98.0.rst:117"
],
"transforms.BboxBase.ymin": [
"doc/api/prev_api_changes/api_changes_0.98.0.rst:109"
],
"triangulation": [
"lib/matplotlib/tri/trirefine.py:docstring of matplotlib.tri.UniformTriRefiner.refine_triangulation:2"
],
Expand Down Expand Up @@ -269,6 +230,12 @@
"matplotlib.backend_bases._Backend": [
"lib/matplotlib/backend_bases.py:docstring of matplotlib.backend_bases.ShowBase:1"
],
"matplotlib.backend_tools._ToolEnableAllNavigation": [
"lib/matplotlib/backend_tools.py:docstring of matplotlib.backend_tools.ToolEnableAllNavigation:1"
],
"matplotlib.backend_tools._ToolEnableNavigation": [
"lib/matplotlib/backend_tools.py:docstring of matplotlib.backend_tools.ToolEnableNavigation:1"
],
"matplotlib.backend_tools._ToolGridBase": [
"lib/matplotlib/backend_tools.py:docstring of matplotlib.backend_tools.ToolGrid:1",
"lib/matplotlib/backend_tools.py:docstring of matplotlib.backend_tools.ToolMinorGrid:1"
Expand Down Expand Up @@ -303,15 +270,9 @@
"matplotlib.contours.ContourSet": [
"lib/mpl_toolkits/axes_grid1/colorbar.py:docstring of mpl_toolkits.axes_grid1.colorbar.colorbar:92"
],
"matplotlib.dates.bytespdate2num": [
"doc/api/dates_api.rst:11"
],
"matplotlib.dates.rrulewrapper": [
"doc/api/dates_api.rst:11"
],
"matplotlib.dates.strpdate2num": [
"doc/api/dates_api.rst:11"
],
"matplotlib.figure._AxesStack": [
"lib/matplotlib/figure.py:docstring of matplotlib.figure.AxesStack:1"
],
Expand Down Expand Up @@ -891,13 +852,13 @@
"doc/api/prev_api_changes/api_changes_3.1.0.rst:933"
],
"axes_grid1": [
"doc/index.rst:154"
"doc/index.rst:157"
],
"axis.Axis.get_ticks_position": [
"doc/api/prev_api_changes/api_changes_3.1.0.rst:821"
],
"axisartist": [
"doc/index.rst:154"
"doc/index.rst:157"
],
"backend_bases.RendererBase": [
"lib/matplotlib/backends/backend_template.py:docstring of matplotlib.backends.backend_template.RendererTemplate:4"
Expand Down Expand Up @@ -983,12 +944,6 @@
"converter": [
"lib/matplotlib/testing/compare.py:docstring of matplotlib.testing.compare.compare_images:4"
],
"dates.bytespdate2num": [
"doc/api/prev_api_changes/api_changes_3.1.0.rst:919"
],
"dates.strpdate2num": [
"doc/api/prev_api_changes/api_changes_3.1.0.rst:918"
],
"fc-list": [
"lib/matplotlib/font_manager.py:docstring of matplotlib.font_manager.get_fontconfig_fonts:2"
],
Expand Down Expand Up @@ -1514,7 +1469,7 @@
"lib/mpl_toolkits/axisartist/axis_artist.py:docstring of mpl_toolkits.axisartist.axis_artist:26"
],
"mplot3d": [
"doc/index.rst:154"
"doc/index.rst:157"
],
"new_figure_manager": [
"doc/devel/MEP/MEP23.rst:75"
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ def gen_candidates():
_deprecated_remain_as_none = {
'animation.avconv_path': ('3.3',),
'animation.avconv_args': ('3.3',),
'keymap.all_axes': ('3.3',),
}


Expand Down
10 changes: 9 additions & 1 deletion lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2321,7 +2321,7 @@ def key_press_handler(event, canvas, toolbar=None):
grid_minor_keys = rcParams['keymap.grid_minor']
toggle_yscale_keys = rcParams['keymap.yscale']
toggle_xscale_keys = rcParams['keymap.xscale']
all_keys = rcParams['keymap.all_axes']
all_keys = dict.__getitem__(rcParams, 'keymap.all_axes')

# toggle fullscreen mode ('f', 'ctrl + f')
if event.key in fullscreen_keys:
Expand Down Expand Up @@ -2443,6 +2443,10 @@ def _get_uniform_gridstate(ticks):
for a in canvas.figure.get_axes():
if (event.x is not None and event.y is not None
and a.in_axes(event)): # FIXME: Why only these?
cbook.warn_deprecated(
"3.3", message="Toggling axes navigation from the "
"keyboard is deprecated since %(since)s and will be "
"removed %(removal)s.")
a.set_navigate(True)
# enable navigation only for axes with this index (if such an axes exist,
# otherwise do nothing)
Expand All @@ -2452,6 +2456,10 @@ def _get_uniform_gridstate(ticks):
for i, a in enumerate(canvas.figure.get_axes()):
if (event.x is not None and event.y is not None
and a.in_axes(event)): # FIXME: Why only these?
cbook.warn_deprecated(
"3.3", message="Toggling axes navigation from the "
"keyboard is deprecated since %(since)s and will be "
"removed %(removal)s.")
a.set_navigate(i == n)


Expand Down
32 changes: 14 additions & 18 deletions lib/matplotlib/backend_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,38 +410,34 @@ def trigger(self, sender, event, data=None):
Gcf.destroy_all()


class ToolEnableAllNavigation(ToolBase):
class _ToolEnableAllNavigation(ToolBase):
"""Tool to enable all axes for toolmanager interaction."""

description = 'Enable all axes toolmanager'
default_keymap = mpl.rcParams['keymap.all_axes']

def trigger(self, sender, event, data=None):
if event.inaxes is None:
return
mpl.backend_bases.key_press_handler(event, self.figure.canvas, None)

for a in self.figure.get_axes():
if (event.x is not None and event.y is not None
and a.in_axes(event)):
a.set_navigate(True)

@cbook.deprecated("3.3")
class ToolEnableAllNavigation(_ToolEnableAllNavigation):
pass


class ToolEnableNavigation(ToolBase):
class _ToolEnableNavigation(ToolBase):
"""Tool to enable a specific axes for toolmanager interaction."""

description = 'Enable one axes toolmanager'
default_keymap = (1, 2, 3, 4, 5, 6, 7, 8, 9)

def trigger(self, sender, event, data=None):
if event.inaxes is None:
return
mpl.backend_bases.key_press_handler(event, self.figure.canvas, None)


n = int(event.key) - 1
if n < len(self.figure.get_axes()):
for i, a in enumerate(self.figure.get_axes()):
if (event.x is not None and event.y is not None
and a.in_axes(event)):
a.set_navigate(i == n)
@cbook.deprecated("3.3")
class ToolEnableNavigation(_ToolEnableNavigation):
pass


class _ToolGridBase(ToolBase):
Expand Down Expand Up @@ -1089,8 +1085,8 @@ def trigger(self, *args, **kwargs):
'fullscreen': ToolFullScreen,
'quit': ToolQuit,
'quit_all': ToolQuitAll,
'allnav': ToolEnableAllNavigation,
'nav': ToolEnableNavigation,
'allnav': _ToolEnableAllNavigation,
'nav': _ToolEnableNavigation,
'xscale': ToolXScale,
'yscale': ToolYScale,
'position': ToolCursorPosition,
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/mpl-data/stylelib/classic.mplstyle
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@ keymap.quit : ctrl+w, cmd+w # close the current figure
keymap.grid : g # switching on/off a grid in current axes
keymap.yscale : l # toggle scaling of y-axes ('log'/'linear')
keymap.xscale : k, L # toggle scaling of x-axes ('log'/'linear')
keymap.all_axes : a # enable all axes

###ANIMATION settings
animation.writer : ffmpeg # MovieWriter 'backend' to use
Expand Down
1 change: 0 additions & 1 deletion matplotlibrc.template
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,6 @@
#keymap.grid_minor: G # switching on/off minor grids in current axes
#keymap.yscale: l # toggle scaling of y-axes ('log'/'linear')
#keymap.xscale: k, L # toggle scaling of x-axes ('log'/'linear')
#keymap.all_axes: a # enable all axes
#keymap.copy: ctrl+c, cmd+c # Copy figure to clipboard


Expand Down